facets 2.5.2 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/HISTORY.rdoc +2245 -0
- data/MANIFEST +20 -725
- data/{README → README.rdoc} +0 -0
- data/RELEASE +37 -48
- data/doc/log/stats/index.html +39 -0
- data/doc/notes/CHANGES +2529 -0
- data/lib/{more → core}/facets/binding/opvars.rb +0 -0
- data/lib/core/facets/integer/length.rb +16 -0
- data/lib/core/facets/kernel/state.rb +50 -0
- data/lib/core/facets/module/extend.rb +2 -2
- data/lib/core/facets/string/camelcase.rb +33 -9
- data/lib/core/facets/string/lowercase.rb +1 -0
- data/lib/core/facets/string/methodize.rb +10 -1
- data/lib/core/facets/string/modulize.rb +8 -0
- data/lib/core/facets/string/pathize.rb +10 -0
- data/lib/core/facets/string/snakecase.rb +2 -2
- data/lib/core/facets/string/underscore.rb +21 -0
- data/lib/core/facets/string/uppercase.rb +23 -0
- data/lib/more/facets/censor.rb +97 -0
- data/lib/more/facets/minitar.rb +11 -11
- data/lib/more/facets/platform.rb +47 -0
- data/lib/more/facets/pry.rb +32 -0
- data/lib/more/facets/string/obfuscate.rb +65 -0
- data/lib/more/facets/string/stylize.rb +169 -0
- data/lib/more/facets/string/words.rb +10 -13
- data/meta/modified +1 -0
- data/meta/package +1 -0
- data/meta/version +1 -0
- data/test/core/integer/test_length.rb +12 -0
- metadata +41 -822
- data/CHANGES +0 -133
- data/VERSION +0 -1
- data/doc/changelogs/CHANGELOG-0.10.30 +0 -239
- data/doc/changelogs/CHANGELOG-1.8.54 +0 -450
- data/doc/changelogs/CHANGELOG-2.4.5 +0 -1654
- data/doc/rdoc/core/classes/Array.html +0 -1208
- data/doc/rdoc/core/classes/Binding.html +0 -364
- data/doc/rdoc/core/classes/Class.html +0 -444
- data/doc/rdoc/core/classes/Comparable.html +0 -250
- data/doc/rdoc/core/classes/Dir.html +0 -395
- data/doc/rdoc/core/classes/Enumerable.html +0 -1262
- data/doc/rdoc/core/classes/Enumerable/Enumerator.html +0 -243
- data/doc/rdoc/core/classes/Enumerator.html +0 -242
- data/doc/rdoc/core/classes/Exception.html +0 -163
- data/doc/rdoc/core/classes/FalseClass.html +0 -131
- data/doc/rdoc/core/classes/File.html +0 -576
- data/doc/rdoc/core/classes/FileTest.html +0 -116
- data/doc/rdoc/core/classes/Float.html +0 -159
- data/doc/rdoc/core/classes/Functor.html +0 -171
- data/doc/rdoc/core/classes/Hash.html +0 -2184
- data/doc/rdoc/core/classes/Indexable.html +0 -629
- data/doc/rdoc/core/classes/InstanceVariables.html +0 -306
- data/doc/rdoc/core/classes/Integer.html +0 -583
- data/doc/rdoc/core/classes/Kernel.html +0 -2269
- data/doc/rdoc/core/classes/Lazy.html +0 -96
- data/doc/rdoc/core/classes/Lazy/Future.html +0 -100
- data/doc/rdoc/core/classes/Lazy/Promise.html +0 -114
- data/doc/rdoc/core/classes/Lazy/PromiseSafe.html +0 -99
- data/doc/rdoc/core/classes/MatchData.html +0 -204
- data/doc/rdoc/core/classes/Module.html +0 -1316
- data/doc/rdoc/core/classes/NilClass.html +0 -217
- data/doc/rdoc/core/classes/Numeric.html +0 -251
- data/doc/rdoc/core/classes/Object.html +0 -161
- data/doc/rdoc/core/classes/ObjectSpace.html +0 -114
- data/doc/rdoc/core/classes/Proc.html +0 -302
- data/doc/rdoc/core/classes/Range.html +0 -360
- data/doc/rdoc/core/classes/Regexp.html +0 -191
- data/doc/rdoc/core/classes/Stackable.html +0 -262
- data/doc/rdoc/core/classes/String.html +0 -2332
- data/doc/rdoc/core/classes/Struct.html +0 -121
- data/doc/rdoc/core/classes/Symbol.html +0 -441
- data/doc/rdoc/core/classes/Time.html +0 -521
- data/doc/rdoc/core/classes/TrueClass.html +0 -131
- data/doc/rdoc/core/classes/UnboundMethod.html +0 -200
- data/doc/rdoc/core/created.rid +0 -1
- data/doc/rdoc/core/files/README.html +0 -287
- data/doc/rdoc/core/files/doc/README_core.html +0 -230
- data/doc/rdoc/core/files/lib/core/facets/array/combination_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/array/conjoin_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/array/delete_rb.html +0 -101
- data/doc/rdoc/core/files/lib/core/facets/array/delete_unless_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/array/delete_values_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/array/index_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/array/indexable_rb.html +0 -97
- data/doc/rdoc/core/files/lib/core/facets/array/merge_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/array/not_empty_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/array/only_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/array/pad_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/array/permutation_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/array/product_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/array/recursively_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/array/rotate_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/array/select_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/array/splice_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/array/stackable_rb.html +0 -97
- data/doc/rdoc/core/files/lib/core/facets/array/traverse_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/array_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/binding/caller_rb.html +0 -97
- data/doc/rdoc/core/files/lib/core/facets/binding/callstack_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/binding/defined_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/binding/eval_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/binding/local_variables_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/binding/self_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/binding_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/bitmask_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/blank_rb.html +0 -97
- data/doc/rdoc/core/files/lib/core/facets/boolean_rb.html +0 -126
- data/doc/rdoc/core/files/lib/core/facets/cattr_rb.html +0 -100
- data/doc/rdoc/core/files/lib/core/facets/class/cattr_accessor_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/class/cattr_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/class/cattr_reader_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/class/cattr_writer_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/class/descendents_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/class/methodize_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/class/pathize_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/class/prepend_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/class/subclasses_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/class/to_proc_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/class_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/comparable/at_least_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/comparable/at_most_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/comparable/bound_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/comparable/cap_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/comparable/clip_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/comparable/cmp_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/comparable/comparable_rb.html +0 -109
- data/doc/rdoc/core/files/lib/core/facets/comparable_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/dir/ascend_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/dir/descend_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/dir/multiglob_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/dir/parent_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/dir/recurse_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/dir_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/enumerable/accumulate_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/enumerable/cluster_by_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/enumerable/collect_rb.html +0 -101
- data/doc/rdoc/core/files/lib/core/facets/enumerable/commonality_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/enumerable/compact_map_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/enumerable/count_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/enumerable/divide_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/enumerable/duplicates_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/enumerable/each_by_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/enumerable/entropy_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/enumerable/frequency_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/enumerable/graph_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/enumerable/group_by_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/enumerable/inject_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/enumerable/map_send_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/enumerable/map_with_index_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/enumerable/mash_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/enumerable/mode_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/enumerable/modulate_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/enumerable/none_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/enumerable/occur_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/enumerable/one_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/enumerable/probability_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/enumerable/split_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/enumerable/sum_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/enumerable/take_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/enumerable/uniq_by_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/enumerable_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/exception/detail_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/exception/suppress_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/exception_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/file/append_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/file/create_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/file/null_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/file/read_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/file/rewrite_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/file/rootname_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/file/split_all_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/file/split_root_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/file/write_rb.html +0 -102
- data/doc/rdoc/core/files/lib/core/facets/file/writelines_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/file_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/filetest/root_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/filetest_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/float/round_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/float_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/functor_rb.html +0 -151
- data/doc/rdoc/core/files/lib/core/facets/hash/alias_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/hash/argumentize_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/hash/at_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/hash/autonew_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/hash/collate_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/hash/dearray_values_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/hash/delete_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/hash/diff_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/hash/except_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/hash/group_by_value_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/hash/insert_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/hash/inverse_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/hash/join_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/hash/keys_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/hash/mash_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/hash/merge_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/hash/new_with_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/hash/op_add_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/hash/op_and_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/hash/op_mul_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/hash/op_or_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/hash/op_push_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/hash/op_rb.html +0 -101
- data/doc/rdoc/core/files/lib/core/facets/hash/op_sub_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/hash/recursive_merge_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/hash/recursively_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/hash/rekey_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/hash/replace_each_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/hash/select_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/hash/slice_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/hash/stringify_keys_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/hash/swap_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/hash/symbolize_keys_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/hash/to_h_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/hash/to_options_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/hash/to_proc_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/hash/to_struct_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/hash/traverse_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/hash/update_each_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/hash/update_keys_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/hash/update_rb.html +0 -103
- data/doc/rdoc/core/files/lib/core/facets/hash/update_values_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/hash/weave_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/hash/zipnew_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/hash_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/indexable_rb.html +0 -113
- data/doc/rdoc/core/files/lib/core/facets/integer/even_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/integer/factorial_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/integer/multiple_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/integer/odd_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/integer/of_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/integer/ordinal_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/integer_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/kernel/__callee___rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/kernel/__class___rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/kernel/__dir___rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/kernel/__get___rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/kernel/__here___rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/kernel/__method___rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/kernel/__set___rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/kernel/as_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/kernel/ask_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/kernel/attr_singleton_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/kernel/callstack_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/kernel/complete_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/kernel/constant_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/kernel/d_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/kernel/deep_copy_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/kernel/demo_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/kernel/ergo_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/kernel/here_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/kernel/in_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/kernel/instance_assign_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/kernel/instance_class_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/kernel/instance_exec_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/kernel/instance_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/kernel/instance_send_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/kernel/instance_variables_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/kernel/maybe_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/kernel/not_nil_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/kernel/object_class_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/kernel/object_hexid_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/kernel/object_send_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/kernel/p_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/kernel/populate_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/kernel/qua_class_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/kernel/require_all_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/kernel/require_local_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/kernel/resc_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/kernel/respond_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/kernel/returning_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/kernel/silence_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/kernel/singleton_class_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/kernel/tap_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/kernel/try_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/kernel/val_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/kernel/with_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/kernel_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/lazy_rb.html +0 -120
- data/doc/rdoc/core/files/lib/core/facets/matchdata/match_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/matchdata/matchset_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/matchdata_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/metaid_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/module/abstract_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/module/alias_accessor_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/module/alias_method_chain_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/module/alias_module_function_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/module/ancestor_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/module/basename_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/module/can_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/module/class_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/module/conflict_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/module/extend_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/module/include_function_module_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/module/instance_methods_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/module/integrate_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/module/is_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/module/methodize_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/module/modspace_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/module/module_load_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/module/nesting_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/module/op_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/module/pathize_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/module/prepend_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/module/redefine_method_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/module/redirect_method_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/module/rename_method_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/module/revise_rb.html +0 -99
- data/doc/rdoc/core/files/lib/core/facets/module/spacename_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/module/wrap_method_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/module_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/nilclass/ergo_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/nilclass/to_f_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/nilclass_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/numeric/approx_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/numeric/distance_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/numeric/round_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/numeric_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/objectspace/classes_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/objectspace_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/proc/bind_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/proc/compose_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/proc/curry_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/proc/to_method_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/proc/update_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/proc_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/range/combine_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/range/overlap_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/range/to_r_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/range/umbrella_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/range/within_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/range_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/regexp/arity_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/regexp/to_re_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/regexp_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/stackable_rb.html +0 -120
- data/doc/rdoc/core/files/lib/core/facets/string/align_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/string/bracket_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/string/bytes_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/string/camelcase_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/string/capitalized_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/string/chars_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/string/chomp_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/string/cleave_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/string/compress_lines_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/string/contains_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/string/divide_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/string/each_char_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/string/each_word_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/string/end_with_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/string/expand_tab_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/string/file_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/string/fold_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/string/indent_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/string/interpolate_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/string/line_wrap_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/string/lines_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/string/margin_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/string/methodize_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/string/modulize_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/string/mscan_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/string/natcmp_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/string/nchar_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/string/op_sub_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/string/outdent_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/string/pathize_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/string/range_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/string/rewrite_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/string/shatter_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/string/snakecase_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/string/splice_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/string/start_with_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/string/subtract_rb.html +0 -100
- data/doc/rdoc/core/files/lib/core/facets/string/tab_rb.html +0 -99
- data/doc/rdoc/core/files/lib/core/facets/string/tabto_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/string/titlecase_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/string/to_re_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/string/variablize_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/string/word_wrap_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/string/words_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/string/xor_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/string_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/struct/attributes_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/struct_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/symbol/chomp_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/symbol/generate_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/symbol/not_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/symbol/plain_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/symbol/query_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/symbol/re_s_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/symbol/setter_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/symbol/succ_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/symbol/to_proc_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/symbol/variablize_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/symbol_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/time/advance_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/time/ago_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/time/change_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/time/elapse_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/time/hence_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/time/round_rb.html +0 -96
- data/doc/rdoc/core/files/lib/core/facets/time/set_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/time/stamp_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/time/to_time_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/time/trunc_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/time_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/to_hash_rb.html +0 -97
- data/doc/rdoc/core/files/lib/core/facets/unboundmethod/arguments_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/unboundmethod/name_rb.html +0 -92
- data/doc/rdoc/core/files/lib/core/facets/unboundmethod_rb.html +0 -92
- data/doc/rdoc/core/fr_class_index.html +0 -85
- data/doc/rdoc/core/fr_file_index.html +0 -381
- data/doc/rdoc/core/fr_method_index.html +0 -520
- data/doc/rdoc/core/index.html +0 -26
- data/doc/rdoc/core/rdoc-style.css +0 -177
- data/doc/rdoc/more/classes/ANSICode.html +0 -493
- data/doc/rdoc/more/classes/Advisable.html +0 -269
- data/doc/rdoc/more/classes/Advisable/Method.html +0 -223
- data/doc/rdoc/more/classes/Archive.html +0 -89
- data/doc/rdoc/more/classes/Archive/Tar.html +0 -89
- data/doc/rdoc/more/classes/Archive/Tar/Minitar.html +0 -469
- data/doc/rdoc/more/classes/Archive/Tar/Minitar/Input.html +0 -355
- data/doc/rdoc/more/classes/Archive/Tar/Minitar/Output.html +0 -216
- data/doc/rdoc/more/classes/Archive/Tar/Minitar/Reader.html +0 -283
- data/doc/rdoc/more/classes/Archive/Tar/Minitar/Writer.html +0 -378
- data/doc/rdoc/more/classes/Argvector.html +0 -487
- data/doc/rdoc/more/classes/Association.html +0 -319
- data/doc/rdoc/more/classes/Association/Kernel.html +0 -131
- data/doc/rdoc/more/classes/Autoarray.html +0 -166
- data/doc/rdoc/more/classes/BBCode.html +0 -532
- data/doc/rdoc/more/classes/BaseX.html +0 -194
- data/doc/rdoc/more/classes/BiCrypt.html +0 -541
- data/doc/rdoc/more/classes/BinReadable.html +0 -485
- data/doc/rdoc/more/classes/BinReadable/ByteOrder.html +0 -223
- data/doc/rdoc/more/classes/Binding.html +0 -146
- data/doc/rdoc/more/classes/BlankSlate.html +0 -129
- data/doc/rdoc/more/classes/Buildable.html +0 -152
- data/doc/rdoc/more/classes/BuildingBlock.html +0 -360
- data/doc/rdoc/more/classes/Capsule.html +0 -408
- data/doc/rdoc/more/classes/Capsule/MissingFile.html +0 -96
- data/doc/rdoc/more/classes/Cloneable.html +0 -129
- data/doc/rdoc/more/classes/ConsoleUtils.html +0 -238
- data/doc/rdoc/more/classes/Coroutine.html +0 -285
- data/doc/rdoc/more/classes/Crypt.html +0 -275
- data/doc/rdoc/more/classes/CssFilter.html +0 -471
- data/doc/rdoc/more/classes/CssTree.html +0 -149
- data/doc/rdoc/more/classes/Dictionary.html +0 -1255
- data/doc/rdoc/more/classes/Downloader.html +0 -512
- data/doc/rdoc/more/classes/Duration.html +0 -691
- data/doc/rdoc/more/classes/Duration/Numeric.html +0 -389
- data/doc/rdoc/more/classes/Duration/Time.html +0 -124
- data/doc/rdoc/more/classes/Enumerable.html +0 -401
- data/doc/rdoc/more/classes/Enumerable/Elementor.html +0 -170
- data/doc/rdoc/more/classes/Enumerable/Enumerator.html +0 -116
- data/doc/rdoc/more/classes/Enumerable/Filterable.html +0 -246
- data/doc/rdoc/more/classes/EnumerablePass.html +0 -214
- data/doc/rdoc/more/classes/Enumerator.html +0 -95
- data/doc/rdoc/more/classes/Enumerator/Filter.html +0 -104
- data/doc/rdoc/more/classes/Equatable.html +0 -188
- data/doc/rdoc/more/classes/Expirable.html +0 -195
- data/doc/rdoc/more/classes/FileList.html +0 -955
- data/doc/rdoc/more/classes/Fileable.html +0 -178
- data/doc/rdoc/more/classes/Fileable/DSL.html +0 -303
- data/doc/rdoc/more/classes/Hash.html +0 -171
- data/doc/rdoc/more/classes/Hash2Xml.html +0 -105
- data/doc/rdoc/more/classes/Hook.html +0 -162
- data/doc/rdoc/more/classes/HtmlFilter.html +0 -329
- data/doc/rdoc/more/classes/IORedirect.html +0 -220
- data/doc/rdoc/more/classes/InfinityClass.html +0 -448
- data/doc/rdoc/more/classes/InfinityClass/Numeric.html +0 -195
- data/doc/rdoc/more/classes/Ini.html +0 -447
- data/doc/rdoc/more/classes/Instantiable.html +0 -140
- data/doc/rdoc/more/classes/Instantize.html +0 -160
- data/doc/rdoc/more/classes/Interval.html +0 -877
- data/doc/rdoc/more/classes/It.html +0 -185
- data/doc/rdoc/more/classes/LRUCache.html +0 -321
- data/doc/rdoc/more/classes/LRUCache/Item.html +0 -114
- data/doc/rdoc/more/classes/LRUCache/Sentinel.html +0 -100
- data/doc/rdoc/more/classes/LinkedList.html +0 -432
- data/doc/rdoc/more/classes/LinkedList/Node.html +0 -149
- data/doc/rdoc/more/classes/Matcher.html +0 -335
- data/doc/rdoc/more/classes/Matcher/MatchData.html +0 -115
- data/doc/rdoc/more/classes/Memoizer.html +0 -240
- data/doc/rdoc/more/classes/MissingArgument.html +0 -97
- data/doc/rdoc/more/classes/Module.html +0 -1224
- data/doc/rdoc/more/classes/Multiton.html +0 -205
- data/doc/rdoc/more/classes/Multiton/Inclusive.html +0 -93
- data/doc/rdoc/more/classes/Multiton/MetaMethods.html +0 -221
- data/doc/rdoc/more/classes/NackClass.html +0 -98
- data/doc/rdoc/more/classes/Net.html +0 -88
- data/doc/rdoc/more/classes/Net/SMTP.html +0 -140
- data/doc/rdoc/more/classes/NullClass.html +0 -202
- data/doc/rdoc/more/classes/Numeric/Multipliers.html +0 -456
- data/doc/rdoc/more/classes/ObjectReflection.html +0 -172
- data/doc/rdoc/more/classes/OpEsc.html +0 -137
- data/doc/rdoc/more/classes/OpenCascade.html +0 -179
- data/doc/rdoc/more/classes/OpenCollection.html +0 -138
- data/doc/rdoc/more/classes/OpenHash.html +0 -157
- data/doc/rdoc/more/classes/OpenModule.html +0 -135
- data/doc/rdoc/more/classes/OpenObject.html +0 -608
- data/doc/rdoc/more/classes/OpenStructable.html +0 -326
- data/doc/rdoc/more/classes/PQueue.html +0 -607
- data/doc/rdoc/more/classes/Paramix.html +0 -201
- data/doc/rdoc/more/classes/Paramix/Delegator.html +0 -215
- data/doc/rdoc/more/classes/PathList.html +0 -159
- data/doc/rdoc/more/classes/PathList/Finder.html +0 -135
- data/doc/rdoc/more/classes/Platform.html +0 -444
- data/doc/rdoc/more/classes/Pool.html +0 -204
- data/doc/rdoc/more/classes/Proc.html +0 -180
- data/doc/rdoc/more/classes/ProgressBar.html +0 -356
- data/doc/rdoc/more/classes/Prototype.html +0 -243
- data/doc/rdoc/more/classes/RWDelegator.html +0 -194
- data/doc/rdoc/more/classes/Random.html +0 -145
- data/doc/rdoc/more/classes/Random/Array.html +0 -339
- data/doc/rdoc/more/classes/Random/Hash.html +0 -378
- data/doc/rdoc/more/classes/Random/Object.html +0 -119
- data/doc/rdoc/more/classes/Random/String.html +0 -299
- data/doc/rdoc/more/classes/Random/String/Self.html +0 -153
- data/doc/rdoc/more/classes/Recorder.html +0 -203
- data/doc/rdoc/more/classes/Reference.html +0 -196
- data/doc/rdoc/more/classes/Registerable.html +0 -157
- data/doc/rdoc/more/classes/Semaphore.html +0 -260
- data/doc/rdoc/more/classes/Settings.html +0 -288
- data/doc/rdoc/more/classes/Settings/Setting.html +0 -223
- data/doc/rdoc/more/classes/Settings/SettingCollection.html +0 -144
- data/doc/rdoc/more/classes/SimpleStringIO.html +0 -135
- data/doc/rdoc/more/classes/Snapshot.html +0 -194
- data/doc/rdoc/more/classes/Snapshot/ValueHolder.html +0 -163
- data/doc/rdoc/more/classes/SparseArray.html +0 -1397
- data/doc/rdoc/more/classes/Stash.html +0 -232
- data/doc/rdoc/more/classes/String/Mask.html +0 -555
- data/doc/rdoc/more/classes/String/Words.html +0 -328
- data/doc/rdoc/more/classes/Struct.html +0 -130
- data/doc/rdoc/more/classes/SyncArray.html +0 -127
- data/doc/rdoc/more/classes/SyncHash.html +0 -158
- data/doc/rdoc/more/classes/SyncHash/Delegator.html +0 -211
- data/doc/rdoc/more/classes/SyncHash/Inheritor.html +0 -211
- data/doc/rdoc/more/classes/System.html +0 -1117
- data/doc/rdoc/more/classes/Timer.html +0 -464
- data/doc/rdoc/more/classes/Timer/Dummy.html +0 -139
- data/doc/rdoc/more/classes/TracePoint.html +0 -455
- data/doc/rdoc/more/classes/Tuple.html +0 -900
- data/doc/rdoc/more/classes/TypeCast.html +0 -158
- data/doc/rdoc/more/classes/TypeCast/Class.html +0 -127
- data/doc/rdoc/more/classes/TypeCast/Object.html +0 -117
- data/doc/rdoc/more/classes/TypeCastException.html +0 -96
- data/doc/rdoc/more/classes/Uninheritable.html +0 -120
- data/doc/rdoc/more/classes/VersionNumber.html +0 -408
- data/doc/rdoc/more/classes/X.html +0 -117
- data/doc/rdoc/more/classes/XOXO.html +0 -189
- data/doc/rdoc/more/classes/ZipUtils.html +0 -568
- data/doc/rdoc/more/classes/ZipUtils/DryRun.html +0 -391
- data/doc/rdoc/more/classes/ZipUtils/NoWrite.html +0 -391
- data/doc/rdoc/more/classes/ZipUtils/Verbose.html +0 -361
- data/doc/rdoc/more/created.rid +0 -1
- data/doc/rdoc/more/files/README.html +0 -286
- data/doc/rdoc/more/files/doc/README_more.html +0 -141
- data/doc/rdoc/more/files/lib/more/facets/1stclassmethod_rb.html +0 -181
- data/doc/rdoc/more/files/lib/more/facets/advisable_rb.html +0 -124
- data/doc/rdoc/more/files/lib/more/facets/ansicode_rb.html +0 -200
- data/doc/rdoc/more/files/lib/more/facets/argvector_rb.html +0 -142
- data/doc/rdoc/more/files/lib/more/facets/association_rb.html +0 -158
- data/doc/rdoc/more/files/lib/more/facets/attr_rb.html +0 -92
- data/doc/rdoc/more/files/lib/more/facets/autoarray_rb.html +0 -125
- data/doc/rdoc/more/files/lib/more/facets/autoreload_rb.html +0 -134
- data/doc/rdoc/more/files/lib/more/facets/basex_rb.html +0 -92
- data/doc/rdoc/more/files/lib/more/facets/bbcode_rb.html +0 -138
- data/doc/rdoc/more/files/lib/more/facets/bicrypt_rb.html +0 -124
- data/doc/rdoc/more/files/lib/more/facets/binding/opvars_rb.html +0 -96
- data/doc/rdoc/more/files/lib/more/facets/binreadable_rb.html +0 -141
- data/doc/rdoc/more/files/lib/more/facets/blankslate_rb.html +0 -92
- data/doc/rdoc/more/files/lib/more/facets/buildable_rb.html +0 -230
- data/doc/rdoc/more/files/lib/more/facets/capsule_rb.html +0 -143
- data/doc/rdoc/more/files/lib/more/facets/class_extension_rb.html +0 -155
- data/doc/rdoc/more/files/lib/more/facets/classmethods_rb.html +0 -213
- data/doc/rdoc/more/files/lib/more/facets/cloneable_rb.html +0 -134
- data/doc/rdoc/more/files/lib/more/facets/consoleutils_rb.html +0 -92
- data/doc/rdoc/more/files/lib/more/facets/coroutine_rb.html +0 -163
- data/doc/rdoc/more/files/lib/more/facets/crypt_rb.html +0 -141
- data/doc/rdoc/more/files/lib/more/facets/cssfilter_rb.html +0 -121
- data/doc/rdoc/more/files/lib/more/facets/daemonize_rb.html +0 -118
- data/doc/rdoc/more/files/lib/more/facets/dependency_rb.html +0 -158
- data/doc/rdoc/more/files/lib/more/facets/dictionary_rb.html +0 -201
- data/doc/rdoc/more/files/lib/more/facets/downloader_rb.html +0 -137
- data/doc/rdoc/more/files/lib/more/facets/duplicable_rb.html +0 -100
- data/doc/rdoc/more/files/lib/more/facets/duration_rb.html +0 -92
- data/doc/rdoc/more/files/lib/more/facets/elementor_rb.html +0 -149
- data/doc/rdoc/more/files/lib/more/facets/elementwise_rb.html +0 -96
- data/doc/rdoc/more/files/lib/more/facets/enumerablepass_rb.html +0 -154
- data/doc/rdoc/more/files/lib/more/facets/equatable_rb.html +0 -146
- data/doc/rdoc/more/files/lib/more/facets/expirable_rb.html +0 -116
- data/doc/rdoc/more/files/lib/more/facets/fileable_rb.html +0 -138
- data/doc/rdoc/more/files/lib/more/facets/filelist_rb.html +0 -165
- data/doc/rdoc/more/files/lib/more/facets/filter_rb.html +0 -97
- data/doc/rdoc/more/files/lib/more/facets/heap_rb.html +0 -132
- data/doc/rdoc/more/files/lib/more/facets/hook_rb.html +0 -96
- data/doc/rdoc/more/files/lib/more/facets/htmlfilter_rb.html +0 -153
- data/doc/rdoc/more/files/lib/more/facets/infinity_rb.html +0 -153
- data/doc/rdoc/more/files/lib/more/facets/inheritor_rb.html +0 -124
- data/doc/rdoc/more/files/lib/more/facets/ini_rb.html +0 -105
- data/doc/rdoc/more/files/lib/more/facets/instantiable_rb.html +0 -119
- data/doc/rdoc/more/files/lib/more/facets/instantise_rb.html +0 -96
- data/doc/rdoc/more/files/lib/more/facets/instantize_rb.html +0 -160
- data/doc/rdoc/more/files/lib/more/facets/interval_rb.html +0 -163
- data/doc/rdoc/more/files/lib/more/facets/ioredirect_rb.html +0 -133
- data/doc/rdoc/more/files/lib/more/facets/iteration_rb.html +0 -94
- data/doc/rdoc/more/files/lib/more/facets/kernel/meta_rb.html +0 -96
- data/doc/rdoc/more/files/lib/more/facets/linkedlist_rb.html +0 -159
- data/doc/rdoc/more/files/lib/more/facets/lrucache_rb.html +0 -129
- data/doc/rdoc/more/files/lib/more/facets/main_rb.html +0 -126
- data/doc/rdoc/more/files/lib/more/facets/matcher_rb.html +0 -97
- data/doc/rdoc/more/files/lib/more/facets/memoize_rb.html +0 -164
- data/doc/rdoc/more/files/lib/more/facets/memoizer_rb.html +0 -152
- data/doc/rdoc/more/files/lib/more/facets/methodspace_rb.html +0 -138
- data/doc/rdoc/more/files/lib/more/facets/minitar_rb.html +0 -203
- data/doc/rdoc/more/files/lib/more/facets/multipliers_rb.html +0 -132
- data/doc/rdoc/more/files/lib/more/facets/multiton_rb.html +0 -187
- data/doc/rdoc/more/files/lib/more/facets/nackclass_rb.html +0 -120
- data/doc/rdoc/more/files/lib/more/facets/net/smtp_tls_rb.html +0 -143
- data/doc/rdoc/more/files/lib/more/facets/nilstatus_rb.html +0 -92
- data/doc/rdoc/more/files/lib/more/facets/nullclass_rb.html +0 -122
- data/doc/rdoc/more/files/lib/more/facets/opencascade_rb.html +0 -114
- data/doc/rdoc/more/files/lib/more/facets/opencollection_rb.html +0 -123
- data/doc/rdoc/more/files/lib/more/facets/openhash_rb.html +0 -107
- data/doc/rdoc/more/files/lib/more/facets/openmodule_rb.html +0 -92
- data/doc/rdoc/more/files/lib/more/facets/openobject_rb.html +0 -169
- data/doc/rdoc/more/files/lib/more/facets/opesc_rb.html +0 -94
- data/doc/rdoc/more/files/lib/more/facets/orderedhash_rb.html +0 -143
- data/doc/rdoc/more/files/lib/more/facets/ostructable_rb.html +0 -92
- data/doc/rdoc/more/files/lib/more/facets/overload_rb.html +0 -119
- data/doc/rdoc/more/files/lib/more/facets/paramix_rb.html +0 -135
- data/doc/rdoc/more/files/lib/more/facets/partial_rb.html +0 -124
- data/doc/rdoc/more/files/lib/more/facets/pathlist_rb.html +0 -133
- data/doc/rdoc/more/files/lib/more/facets/platform_rb.html +0 -103
- data/doc/rdoc/more/files/lib/more/facets/pool_rb.html +0 -131
- data/doc/rdoc/more/files/lib/more/facets/pqueue_rb.html +0 -128
- data/doc/rdoc/more/files/lib/more/facets/progressbar_rb.html +0 -126
- data/doc/rdoc/more/files/lib/more/facets/prototype_rb.html +0 -102
- data/doc/rdoc/more/files/lib/more/facets/random_rb.html +0 -149
- data/doc/rdoc/more/files/lib/more/facets/rbsystem_rb.html +0 -144
- data/doc/rdoc/more/files/lib/more/facets/recorder_rb.html +0 -154
- data/doc/rdoc/more/files/lib/more/facets/reference_rb.html +0 -130
- data/doc/rdoc/more/files/lib/more/facets/reflection_rb.html +0 -134
- data/doc/rdoc/more/files/lib/more/facets/registerable_rb.html +0 -98
- data/doc/rdoc/more/files/lib/more/facets/rwdelegator_rb.html +0 -122
- data/doc/rdoc/more/files/lib/more/facets/semaphore_rb.html +0 -120
- data/doc/rdoc/more/files/lib/more/facets/settings_rb.html +0 -141
- data/doc/rdoc/more/files/lib/more/facets/snapshot_rb.html +0 -177
- data/doc/rdoc/more/files/lib/more/facets/sparse_array_rb.html +0 -92
- data/doc/rdoc/more/files/lib/more/facets/stash_rb.html +0 -166
- data/doc/rdoc/more/files/lib/more/facets/string/mask_rb.html +0 -96
- data/doc/rdoc/more/files/lib/more/facets/string/words_rb.html +0 -96
- data/doc/rdoc/more/files/lib/more/facets/succ_rb.html +0 -92
- data/doc/rdoc/more/files/lib/more/facets/syncarray_rb.html +0 -125
- data/doc/rdoc/more/files/lib/more/facets/synchash_rb.html +0 -138
- data/doc/rdoc/more/files/lib/more/facets/thread_rb.html +0 -132
- data/doc/rdoc/more/files/lib/more/facets/timer_rb.html +0 -174
- data/doc/rdoc/more/files/lib/more/facets/tracepoint_rb.html +0 -172
- data/doc/rdoc/more/files/lib/more/facets/tuple_rb.html +0 -160
- data/doc/rdoc/more/files/lib/more/facets/typecast_rb.html +0 -215
- data/doc/rdoc/more/files/lib/more/facets/uninheritable_rb.html +0 -129
- data/doc/rdoc/more/files/lib/more/facets/version_rb.html +0 -132
- data/doc/rdoc/more/files/lib/more/facets/xmlhash_rb.html +0 -97
- data/doc/rdoc/more/files/lib/more/facets/xoxo_rb.html +0 -136
- data/doc/rdoc/more/files/lib/more/facets/ziputils_rb.html +0 -105
- data/doc/rdoc/more/fr_class_index.html +0 -185
- data/doc/rdoc/more/fr_file_index.html +0 -156
- data/doc/rdoc/more/fr_method_index.html +0 -1132
- data/doc/rdoc/more/index.html +0 -26
- data/doc/rdoc/more/rdoc-style.css +0 -177
- data/lib/core/facets/kernel/__here__.rb +0 -8
- data/lib/more/facets/buildable.rb +0 -344
- data/lib/more/facets/cssfilter.rb +0 -254
- data/lib/more/facets/htmlfilter.rb +0 -595
- data/lib/more/facets/kernel/meta.rb +0 -32
- data/lib/more/facets/prototype.rb +0 -88
- data/lib/more/facets/rwdelegator.rb +0 -74
@@ -1,116 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
<html>
|
6
|
-
<head>
|
7
|
-
<title>Module: FileTest</title>
|
8
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
9
|
-
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
10
|
-
|
11
|
-
<script language="JavaScript" type="text/javascript">
|
12
|
-
// <![CDATA[
|
13
|
-
|
14
|
-
function toggleSource( id )
|
15
|
-
{
|
16
|
-
var elem
|
17
|
-
var link
|
18
|
-
|
19
|
-
if( document.getElementById )
|
20
|
-
{
|
21
|
-
elem = document.getElementById( id )
|
22
|
-
link = document.getElementById( "l_" + id )
|
23
|
-
}
|
24
|
-
else if ( document.all )
|
25
|
-
{
|
26
|
-
elem = eval( "document.all." + id )
|
27
|
-
link = eval( "document.all.l_" + id )
|
28
|
-
}
|
29
|
-
else
|
30
|
-
return false;
|
31
|
-
|
32
|
-
if( elem.style.display == "block" )
|
33
|
-
{
|
34
|
-
elem.style.display = "none"
|
35
|
-
link.innerHTML = "+"
|
36
|
-
}
|
37
|
-
else
|
38
|
-
{
|
39
|
-
elem.style.display = "block"
|
40
|
-
link.innerHTML = "-"
|
41
|
-
}
|
42
|
-
}
|
43
|
-
|
44
|
-
function openCode( url )
|
45
|
-
{
|
46
|
-
window.open( url, "SOURCE_CODE", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=480,width=750" ).focus();
|
47
|
-
}
|
48
|
-
// ]]>
|
49
|
-
</script>
|
50
|
-
</head>
|
51
|
-
|
52
|
-
<body>
|
53
|
-
<table width="100%" border='0' cellpadding='0' cellspacing='0' class='banner'><tr>
|
54
|
-
<td class="file-title"><span class="file-title-prefix">Module</span><br />FileTest</td>
|
55
|
-
<td align="right">
|
56
|
-
<table cellspacing="0" cellpadding="2">
|
57
|
-
<tr valign="top">
|
58
|
-
<td>In:</td>
|
59
|
-
<td>
|
60
|
-
<a href="../files/lib/core/facets/filetest/root_rb.html">lib/core/facets/filetest/root.rb</a>
|
61
|
-
</td>
|
62
|
-
</tr>
|
63
|
-
</table>
|
64
|
-
</td>
|
65
|
-
</tr>
|
66
|
-
</table>
|
67
|
-
<!-- banner header -->
|
68
|
-
|
69
|
-
<div id="bodyContent">
|
70
|
-
<div id="content">
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
<div class="sectiontitle">Methods</div>
|
76
|
-
<span style="padding-right: 5px;"><a href="#M000360">root?</a></span>
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
<div class="sectiontitle">Public Instance methods</div>
|
84
|
-
<div class="method">
|
85
|
-
<div class="title">
|
86
|
-
<a name="M000360"></a><b>root?</b>(dir=nil)
|
87
|
-
</div>
|
88
|
-
<div class="description">
|
89
|
-
<p>
|
90
|
-
Is the specified directory the root directory?
|
91
|
-
</p>
|
92
|
-
<p>
|
93
|
-
CREDIT: Jeffrey Schwab
|
94
|
-
</p>
|
95
|
-
</div>
|
96
|
-
<div class="sourcecode">
|
97
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000360_source')" id="l_M000360_source">+</a> ]</p>
|
98
|
-
<div id="M000360_source" class="dyn-source">
|
99
|
-
<pre>
|
100
|
-
<span class="ruby-comment cmt"># File lib/core/facets/filetest/root.rb, line 9</span>
|
101
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">root?</span>(<span class="ruby-identifier">dir</span>=<span class="ruby-keyword kw">nil</span>)
|
102
|
-
<span class="ruby-identifier">pth</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">dir</span><span class="ruby-operator">||</span><span class="ruby-constant">Dir</span>.<span class="ruby-identifier">pwd</span>)
|
103
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">pth</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'/'</span>
|
104
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">pth</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^(\w:)?\/$/</span>
|
105
|
-
<span class="ruby-keyword kw">false</span>
|
106
|
-
<span class="ruby-keyword kw">end</span>
|
107
|
-
</pre>
|
108
|
-
</div>
|
109
|
-
</div>
|
110
|
-
</div>
|
111
|
-
</div>
|
112
|
-
|
113
|
-
</div>
|
114
|
-
|
115
|
-
</body>
|
116
|
-
</html>
|
@@ -1,159 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
<html>
|
6
|
-
<head>
|
7
|
-
<title>Class: Float</title>
|
8
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
9
|
-
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
10
|
-
|
11
|
-
<script language="JavaScript" type="text/javascript">
|
12
|
-
// <![CDATA[
|
13
|
-
|
14
|
-
function toggleSource( id )
|
15
|
-
{
|
16
|
-
var elem
|
17
|
-
var link
|
18
|
-
|
19
|
-
if( document.getElementById )
|
20
|
-
{
|
21
|
-
elem = document.getElementById( id )
|
22
|
-
link = document.getElementById( "l_" + id )
|
23
|
-
}
|
24
|
-
else if ( document.all )
|
25
|
-
{
|
26
|
-
elem = eval( "document.all." + id )
|
27
|
-
link = eval( "document.all.l_" + id )
|
28
|
-
}
|
29
|
-
else
|
30
|
-
return false;
|
31
|
-
|
32
|
-
if( elem.style.display == "block" )
|
33
|
-
{
|
34
|
-
elem.style.display = "none"
|
35
|
-
link.innerHTML = "+"
|
36
|
-
}
|
37
|
-
else
|
38
|
-
{
|
39
|
-
elem.style.display = "block"
|
40
|
-
link.innerHTML = "-"
|
41
|
-
}
|
42
|
-
}
|
43
|
-
|
44
|
-
function openCode( url )
|
45
|
-
{
|
46
|
-
window.open( url, "SOURCE_CODE", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=480,width=750" ).focus();
|
47
|
-
}
|
48
|
-
// ]]>
|
49
|
-
</script>
|
50
|
-
</head>
|
51
|
-
|
52
|
-
<body>
|
53
|
-
<table width="100%" border='0' cellpadding='0' cellspacing='0' class='banner'><tr>
|
54
|
-
<td class="file-title"><span class="file-title-prefix">Class</span><br />Float</td>
|
55
|
-
<td align="right">
|
56
|
-
<table cellspacing="0" cellpadding="2">
|
57
|
-
<tr valign="top">
|
58
|
-
<td>In:</td>
|
59
|
-
<td>
|
60
|
-
<a href="../files/lib/core/facets/numeric/round_rb.html">lib/core/facets/numeric/round.rb</a>
|
61
|
-
</td>
|
62
|
-
</tr>
|
63
|
-
<tr>
|
64
|
-
<td>Parent:</td>
|
65
|
-
<td>
|
66
|
-
<a href="Object.html">
|
67
|
-
Object
|
68
|
-
</a>
|
69
|
-
</td>
|
70
|
-
</tr>
|
71
|
-
</table>
|
72
|
-
</td>
|
73
|
-
</tr>
|
74
|
-
</table>
|
75
|
-
<!-- banner header -->
|
76
|
-
|
77
|
-
<div id="bodyContent">
|
78
|
-
<div id="content">
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
<div class="sectiontitle">Methods</div>
|
84
|
-
<span style="padding-right: 5px;"><a href="#M000223">round_at</a></span>
|
85
|
-
<span style="padding-right: 5px;"><a href="#M000224">round_to</a></span>
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
<div class="sectiontitle">Public Instance methods</div>
|
93
|
-
<div class="method">
|
94
|
-
<div class="title">
|
95
|
-
<a name="M000223"></a><b>round_at</b>( d )
|
96
|
-
</div>
|
97
|
-
<div class="description">
|
98
|
-
<p>
|
99
|
-
Rounds to the given decimal position.
|
100
|
-
</p>
|
101
|
-
<pre>
|
102
|
-
4.555.round_at(0) #=> 5.0
|
103
|
-
4.555.round_at(1) #=> 4.6
|
104
|
-
4.555.round_at(2) #=> 4.56
|
105
|
-
4.555.round_at(3) #=> 4.555
|
106
|
-
</pre>
|
107
|
-
<p>
|
108
|
-
CREDIT: Trans
|
109
|
-
</p>
|
110
|
-
</div>
|
111
|
-
<div class="sourcecode">
|
112
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000223_source')" id="l_M000223_source">+</a> ]</p>
|
113
|
-
<div id="M000223_source" class="dyn-source">
|
114
|
-
<pre>
|
115
|
-
<span class="ruby-comment cmt"># File lib/core/facets/numeric/round.rb, line 50</span>
|
116
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">round_at</span>( <span class="ruby-identifier">d</span> ) <span class="ruby-comment cmt">#d=0</span>
|
117
|
-
(<span class="ruby-keyword kw">self</span> <span class="ruby-operator">*</span> (<span class="ruby-value">10.0</span> <span class="ruby-operator">**</span> <span class="ruby-identifier">d</span>)).<span class="ruby-identifier">round</span>.<span class="ruby-identifier">to_f</span> <span class="ruby-operator">/</span> (<span class="ruby-value">10.0</span> <span class="ruby-operator">**</span> <span class="ruby-identifier">d</span>)
|
118
|
-
<span class="ruby-keyword kw">end</span>
|
119
|
-
</pre>
|
120
|
-
</div>
|
121
|
-
</div>
|
122
|
-
</div>
|
123
|
-
<div class="method">
|
124
|
-
<div class="title">
|
125
|
-
<a name="M000224"></a><b>round_to</b>( n )
|
126
|
-
</div>
|
127
|
-
<div class="description">
|
128
|
-
<p>
|
129
|
-
Rounds to the nearest _n_th degree.
|
130
|
-
</p>
|
131
|
-
<pre>
|
132
|
-
4.555.round_to(1) #=> 5.0
|
133
|
-
4.555.round_to(0.1) #=> 4.6
|
134
|
-
4.555.round_to(0.01) #=> 4.56
|
135
|
-
4.555.round_to(0) #=> 4.555
|
136
|
-
</pre>
|
137
|
-
<p>
|
138
|
-
CREDIT: Trans
|
139
|
-
</p>
|
140
|
-
</div>
|
141
|
-
<div class="sourcecode">
|
142
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000224_source')" id="l_M000224_source">+</a> ]</p>
|
143
|
-
<div id="M000224_source" class="dyn-source">
|
144
|
-
<pre>
|
145
|
-
<span class="ruby-comment cmt"># File lib/core/facets/numeric/round.rb, line 63</span>
|
146
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">round_to</span>( <span class="ruby-identifier">n</span> ) <span class="ruby-comment cmt">#n=1</span>
|
147
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">n</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
|
148
|
-
(<span class="ruby-keyword kw">self</span> <span class="ruby-operator">*</span> (<span class="ruby-value">1.0</span> <span class="ruby-operator">/</span> <span class="ruby-identifier">n</span>)).<span class="ruby-identifier">round</span>.<span class="ruby-identifier">to_f</span> <span class="ruby-operator">/</span> (<span class="ruby-value">1.0</span> <span class="ruby-operator">/</span> <span class="ruby-identifier">n</span>)
|
149
|
-
<span class="ruby-keyword kw">end</span>
|
150
|
-
</pre>
|
151
|
-
</div>
|
152
|
-
</div>
|
153
|
-
</div>
|
154
|
-
</div>
|
155
|
-
|
156
|
-
</div>
|
157
|
-
|
158
|
-
</body>
|
159
|
-
</html>
|
@@ -1,171 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
<html>
|
6
|
-
<head>
|
7
|
-
<title>Class: Functor</title>
|
8
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
9
|
-
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
10
|
-
|
11
|
-
<script language="JavaScript" type="text/javascript">
|
12
|
-
// <![CDATA[
|
13
|
-
|
14
|
-
function toggleSource( id )
|
15
|
-
{
|
16
|
-
var elem
|
17
|
-
var link
|
18
|
-
|
19
|
-
if( document.getElementById )
|
20
|
-
{
|
21
|
-
elem = document.getElementById( id )
|
22
|
-
link = document.getElementById( "l_" + id )
|
23
|
-
}
|
24
|
-
else if ( document.all )
|
25
|
-
{
|
26
|
-
elem = eval( "document.all." + id )
|
27
|
-
link = eval( "document.all.l_" + id )
|
28
|
-
}
|
29
|
-
else
|
30
|
-
return false;
|
31
|
-
|
32
|
-
if( elem.style.display == "block" )
|
33
|
-
{
|
34
|
-
elem.style.display = "none"
|
35
|
-
link.innerHTML = "+"
|
36
|
-
}
|
37
|
-
else
|
38
|
-
{
|
39
|
-
elem.style.display = "block"
|
40
|
-
link.innerHTML = "-"
|
41
|
-
}
|
42
|
-
}
|
43
|
-
|
44
|
-
function openCode( url )
|
45
|
-
{
|
46
|
-
window.open( url, "SOURCE_CODE", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=480,width=750" ).focus();
|
47
|
-
}
|
48
|
-
// ]]>
|
49
|
-
</script>
|
50
|
-
</head>
|
51
|
-
|
52
|
-
<body>
|
53
|
-
<table width="100%" border='0' cellpadding='0' cellspacing='0' class='banner'><tr>
|
54
|
-
<td class="file-title"><span class="file-title-prefix">Class</span><br />Functor</td>
|
55
|
-
<td align="right">
|
56
|
-
<table cellspacing="0" cellpadding="2">
|
57
|
-
<tr valign="top">
|
58
|
-
<td>In:</td>
|
59
|
-
<td>
|
60
|
-
<a href="../files/lib/core/facets/functor_rb.html">lib/core/facets/functor.rb</a>
|
61
|
-
</td>
|
62
|
-
</tr>
|
63
|
-
<tr>
|
64
|
-
<td>Parent:</td>
|
65
|
-
<td>
|
66
|
-
<a href="Object.html">
|
67
|
-
Object
|
68
|
-
</a>
|
69
|
-
</td>
|
70
|
-
</tr>
|
71
|
-
</table>
|
72
|
-
</td>
|
73
|
-
</tr>
|
74
|
-
</table>
|
75
|
-
<!-- banner header -->
|
76
|
-
|
77
|
-
<div id="bodyContent">
|
78
|
-
<div id="content">
|
79
|
-
|
80
|
-
<div class="description"><p>
|
81
|
-
By definition a <a href="Functor.html">Functor</a> is simply a first class
|
82
|
-
method, but these are common in the form of Method and <a
|
83
|
-
href="Proc.html">Proc</a>. So for Ruby a <a href="Functor.html">Functor</a>
|
84
|
-
is a more specialized as a Higher-order function or Metafunction.
|
85
|
-
Essentally, a <a href="Functor.html">Functor</a> can vary its behavior
|
86
|
-
accorrding to the operation applied to it.
|
87
|
-
</p>
|
88
|
-
<pre>
|
89
|
-
f = Functor.new { |op, x| x.send(op, x) }
|
90
|
-
f + 1 #=> 2
|
91
|
-
f + 2 #=> 4
|
92
|
-
f + 3 #=> 6
|
93
|
-
f * 1 #=> 1
|
94
|
-
f * 2 #=> 4
|
95
|
-
f * 3 #=> 9
|
96
|
-
</pre>
|
97
|
-
</div>
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
<div class="sectiontitle">Methods</div>
|
102
|
-
<span style="padding-right: 5px;"><a href="#M000240">method_missing</a></span>
|
103
|
-
<span style="padding-right: 5px;"><a href="#M000238">new</a></span>
|
104
|
-
<span style="padding-right: 5px;"><a href="#M000239">to_proc</a></span>
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
<div class="sectiontitle">Public Class methods</div>
|
112
|
-
<div class="method">
|
113
|
-
<div class="title">
|
114
|
-
<a name="M000238"></a><b>new</b>(&function)
|
115
|
-
</div>
|
116
|
-
<div class="sourcecode">
|
117
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000238_source')" id="l_M000238_source">+</a> ]</p>
|
118
|
-
<div id="M000238_source" class="dyn-source">
|
119
|
-
<pre>
|
120
|
-
<span class="ruby-comment cmt"># File lib/core/facets/functor.rb, line 63</span>
|
121
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">function</span>)
|
122
|
-
<span class="ruby-ivar">@function</span> = <span class="ruby-identifier">function</span>
|
123
|
-
<span class="ruby-keyword kw">end</span>
|
124
|
-
</pre>
|
125
|
-
</div>
|
126
|
-
</div>
|
127
|
-
</div>
|
128
|
-
<div class="sectiontitle">Public Instance methods</div>
|
129
|
-
<div class="method">
|
130
|
-
<div class="title">
|
131
|
-
<a name="M000240"></a><b>method_missing</b>(op, *args, &blk)
|
132
|
-
</div>
|
133
|
-
<div class="description">
|
134
|
-
<p>
|
135
|
-
Any action against the functor is processesd by the function.
|
136
|
-
</p>
|
137
|
-
</div>
|
138
|
-
<div class="sourcecode">
|
139
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000240_source')" id="l_M000240_source">+</a> ]</p>
|
140
|
-
<div id="M000240_source" class="dyn-source">
|
141
|
-
<pre>
|
142
|
-
<span class="ruby-comment cmt"># File lib/core/facets/functor.rb, line 72</span>
|
143
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">method_missing</span>(<span class="ruby-identifier">op</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">blk</span>)
|
144
|
-
<span class="ruby-ivar">@function</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">op</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">blk</span>)
|
145
|
-
<span class="ruby-keyword kw">end</span>
|
146
|
-
</pre>
|
147
|
-
</div>
|
148
|
-
</div>
|
149
|
-
</div>
|
150
|
-
<div class="method">
|
151
|
-
<div class="title">
|
152
|
-
<a name="M000239"></a><b>to_proc</b>()
|
153
|
-
</div>
|
154
|
-
<div class="sourcecode">
|
155
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000239_source')" id="l_M000239_source">+</a> ]</p>
|
156
|
-
<div id="M000239_source" class="dyn-source">
|
157
|
-
<pre>
|
158
|
-
<span class="ruby-comment cmt"># File lib/core/facets/functor.rb, line 67</span>
|
159
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_proc</span>
|
160
|
-
<span class="ruby-ivar">@function</span>
|
161
|
-
<span class="ruby-keyword kw">end</span>
|
162
|
-
</pre>
|
163
|
-
</div>
|
164
|
-
</div>
|
165
|
-
</div>
|
166
|
-
</div>
|
167
|
-
|
168
|
-
</div>
|
169
|
-
|
170
|
-
</body>
|
171
|
-
</html>
|
@@ -1,2184 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
<html>
|
6
|
-
<head>
|
7
|
-
<title>Class: Hash</title>
|
8
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
9
|
-
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
10
|
-
|
11
|
-
<script language="JavaScript" type="text/javascript">
|
12
|
-
// <![CDATA[
|
13
|
-
|
14
|
-
function toggleSource( id )
|
15
|
-
{
|
16
|
-
var elem
|
17
|
-
var link
|
18
|
-
|
19
|
-
if( document.getElementById )
|
20
|
-
{
|
21
|
-
elem = document.getElementById( id )
|
22
|
-
link = document.getElementById( "l_" + id )
|
23
|
-
}
|
24
|
-
else if ( document.all )
|
25
|
-
{
|
26
|
-
elem = eval( "document.all." + id )
|
27
|
-
link = eval( "document.all.l_" + id )
|
28
|
-
}
|
29
|
-
else
|
30
|
-
return false;
|
31
|
-
|
32
|
-
if( elem.style.display == "block" )
|
33
|
-
{
|
34
|
-
elem.style.display = "none"
|
35
|
-
link.innerHTML = "+"
|
36
|
-
}
|
37
|
-
else
|
38
|
-
{
|
39
|
-
elem.style.display = "block"
|
40
|
-
link.innerHTML = "-"
|
41
|
-
}
|
42
|
-
}
|
43
|
-
|
44
|
-
function openCode( url )
|
45
|
-
{
|
46
|
-
window.open( url, "SOURCE_CODE", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=480,width=750" ).focus();
|
47
|
-
}
|
48
|
-
// ]]>
|
49
|
-
</script>
|
50
|
-
</head>
|
51
|
-
|
52
|
-
<body>
|
53
|
-
<table width="100%" border='0' cellpadding='0' cellspacing='0' class='banner'><tr>
|
54
|
-
<td class="file-title"><span class="file-title-prefix">Class</span><br />Hash</td>
|
55
|
-
<td align="right">
|
56
|
-
<table cellspacing="0" cellpadding="2">
|
57
|
-
<tr valign="top">
|
58
|
-
<td>In:</td>
|
59
|
-
<td>
|
60
|
-
<a href="../files/lib/core/facets/to_hash_rb.html">lib/core/facets/to_hash.rb</a>
|
61
|
-
<a href="../files/lib/core/facets/hash/new_with_rb.html">lib/core/facets/hash/new_with.rb</a>
|
62
|
-
<a href="../files/lib/core/facets/hash/zipnew_rb.html">lib/core/facets/hash/zipnew.rb</a>
|
63
|
-
<a href="../files/lib/core/facets/hash/dearray_values_rb.html">lib/core/facets/hash/dearray_values.rb</a>
|
64
|
-
<a href="../files/lib/core/facets/hash/update_values_rb.html">lib/core/facets/hash/update_values.rb</a>
|
65
|
-
<a href="../files/lib/core/facets/hash/alias_rb.html">lib/core/facets/hash/alias.rb</a>
|
66
|
-
<a href="../files/lib/core/facets/hash/autonew_rb.html">lib/core/facets/hash/autonew.rb</a>
|
67
|
-
<a href="../files/lib/core/facets/hash/recursively_rb.html">lib/core/facets/hash/recursively.rb</a>
|
68
|
-
<a href="../files/lib/core/facets/hash/op_and_rb.html">lib/core/facets/hash/op_and.rb</a>
|
69
|
-
<a href="../files/lib/core/facets/hash/op_sub_rb.html">lib/core/facets/hash/op_sub.rb</a>
|
70
|
-
<a href="../files/lib/core/facets/hash/except_rb.html">lib/core/facets/hash/except.rb</a>
|
71
|
-
<a href="../files/lib/core/facets/hash/keys_rb.html">lib/core/facets/hash/keys.rb</a>
|
72
|
-
<a href="../files/lib/core/facets/hash/merge_rb.html">lib/core/facets/hash/merge.rb</a>
|
73
|
-
<a href="../files/lib/core/facets/hash/traverse_rb.html">lib/core/facets/hash/traverse.rb</a>
|
74
|
-
<a href="../files/lib/core/facets/hash/op_or_rb.html">lib/core/facets/hash/op_or.rb</a>
|
75
|
-
<a href="../files/lib/core/facets/hash/op_mul_rb.html">lib/core/facets/hash/op_mul.rb</a>
|
76
|
-
<a href="../files/lib/core/facets/hash/op_push_rb.html">lib/core/facets/hash/op_push.rb</a>
|
77
|
-
<a href="../files/lib/core/facets/hash/inverse_rb.html">lib/core/facets/hash/inverse.rb</a>
|
78
|
-
<a href="../files/lib/core/facets/hash/recursive_merge_rb.html">lib/core/facets/hash/recursive_merge.rb</a>
|
79
|
-
<a href="../files/lib/core/facets/hash/to_proc_rb.html">lib/core/facets/hash/to_proc.rb</a>
|
80
|
-
<a href="../files/lib/core/facets/hash/insert_rb.html">lib/core/facets/hash/insert.rb</a>
|
81
|
-
<a href="../files/lib/core/facets/hash/select_rb.html">lib/core/facets/hash/select.rb</a>
|
82
|
-
<a href="../files/lib/core/facets/hash/diff_rb.html">lib/core/facets/hash/diff.rb</a>
|
83
|
-
<a href="../files/lib/core/facets/hash/mash_rb.html">lib/core/facets/hash/mash.rb</a>
|
84
|
-
<a href="../files/lib/core/facets/hash/collate_rb.html">lib/core/facets/hash/collate.rb</a>
|
85
|
-
<a href="../files/lib/core/facets/hash/delete_rb.html">lib/core/facets/hash/delete.rb</a>
|
86
|
-
<a href="../files/lib/core/facets/hash/weave_rb.html">lib/core/facets/hash/weave.rb</a>
|
87
|
-
<a href="../files/lib/core/facets/hash/swap_rb.html">lib/core/facets/hash/swap.rb</a>
|
88
|
-
<a href="../files/lib/core/facets/hash/to_struct_rb.html">lib/core/facets/hash/to_struct.rb</a>
|
89
|
-
<a href="../files/lib/core/facets/hash/symbolize_keys_rb.html">lib/core/facets/hash/symbolize_keys.rb</a>
|
90
|
-
<a href="../files/lib/core/facets/hash/join_rb.html">lib/core/facets/hash/join.rb</a>
|
91
|
-
<a href="../files/lib/core/facets/hash/group_by_value_rb.html">lib/core/facets/hash/group_by_value.rb</a>
|
92
|
-
<a href="../files/lib/core/facets/hash/replace_each_rb.html">lib/core/facets/hash/replace_each.rb</a>
|
93
|
-
<a href="../files/lib/core/facets/hash/slice_rb.html">lib/core/facets/hash/slice.rb</a>
|
94
|
-
<a href="../files/lib/core/facets/hash/op_add_rb.html">lib/core/facets/hash/op_add.rb</a>
|
95
|
-
<a href="../files/lib/core/facets/hash/rekey_rb.html">lib/core/facets/hash/rekey.rb</a>
|
96
|
-
<a href="../files/lib/core/facets/hash/update_each_rb.html">lib/core/facets/hash/update_each.rb</a>
|
97
|
-
<a href="../files/lib/core/facets/hash/update_keys_rb.html">lib/core/facets/hash/update_keys.rb</a>
|
98
|
-
<a href="../files/lib/core/facets/hash/argumentize_rb.html">lib/core/facets/hash/argumentize.rb</a>
|
99
|
-
<a href="../files/lib/core/facets/hash/at_rb.html">lib/core/facets/hash/at.rb</a>
|
100
|
-
<a href="../files/lib/core/facets/blank_rb.html">lib/core/facets/blank.rb</a>
|
101
|
-
</td>
|
102
|
-
</tr>
|
103
|
-
<tr>
|
104
|
-
<td>Parent:</td>
|
105
|
-
<td>
|
106
|
-
<a href="Object.html">
|
107
|
-
Object
|
108
|
-
</a>
|
109
|
-
</td>
|
110
|
-
</tr>
|
111
|
-
</table>
|
112
|
-
</td>
|
113
|
-
</tr>
|
114
|
-
</table>
|
115
|
-
<!-- banner header -->
|
116
|
-
|
117
|
-
<div id="bodyContent">
|
118
|
-
<div id="content">
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
<div class="sectiontitle">Methods</div>
|
124
|
-
<span style="padding-right: 5px;"><a href="#M000086">&</a></span>
|
125
|
-
<span style="padding-right: 5px;"><a href="#M000101">*</a></span>
|
126
|
-
<span style="padding-right: 5px;"><a href="#M000130">+</a></span>
|
127
|
-
<span style="padding-right: 5px;"><a href="#M000087">-</a></span>
|
128
|
-
<span style="padding-right: 5px;"><a href="#M000102"><<</a></span>
|
129
|
-
<span style="padding-right: 5px;"><a href="#M000082">alias!</a></span>
|
130
|
-
<span style="padding-right: 5px;"><a href="#M000135">argumentize</a></span>
|
131
|
-
<span style="padding-right: 5px;"><a href="#M000083">autonew</a></span>
|
132
|
-
<span style="padding-right: 5px;"><a href="#M000113">collate</a></span>
|
133
|
-
<span style="padding-right: 5px;"><a href="#M000114">collate!</a></span>
|
134
|
-
<span style="padding-right: 5px;"><a href="#M000080">dearray_singular_values</a></span>
|
135
|
-
<span style="padding-right: 5px;"><a href="#M000079">dearray_values</a></span>
|
136
|
-
<span style="padding-right: 5px;"><a href="#M000115">delete_unless</a></span>
|
137
|
-
<span style="padding-right: 5px;"><a href="#M000116">delete_values</a></span>
|
138
|
-
<span style="padding-right: 5px;"><a href="#M000117">delete_values_at</a></span>
|
139
|
-
<span style="padding-right: 5px;"><a href="#M000110">diff</a></span>
|
140
|
-
<span style="padding-right: 5px;"><a href="#M000094">each_with_key</a></span>
|
141
|
-
<span style="padding-right: 5px;"><a href="#M000088">except</a></span>
|
142
|
-
<span style="padding-right: 5px;"><a href="#M000089">except!</a></span>
|
143
|
-
<span style="padding-right: 5px;"><a href="#M000112">graph!</a></span>
|
144
|
-
<span style="padding-right: 5px;"><a href="#M000126">group_by_value</a></span>
|
145
|
-
<span style="padding-right: 5px;"><a href="#M000090">has_keys?</a></span>
|
146
|
-
<span style="padding-right: 5px;"><a href="#M000092">has_only_keys?</a></span>
|
147
|
-
<span style="padding-right: 5px;"><a href="#M000108">insert</a></span>
|
148
|
-
<span style="padding-right: 5px;"><a href="#M000103">inverse</a></span>
|
149
|
-
<span style="padding-right: 5px;"><a href="#M000125">join</a></span>
|
150
|
-
<span style="padding-right: 5px;"><a href="#M000091">keys?</a></span>
|
151
|
-
<span style="padding-right: 5px;"><a href="#M000111">mash!</a></span>
|
152
|
-
<span style="padding-right: 5px;"><a href="#M000077">new_with</a></span>
|
153
|
-
<span style="padding-right: 5px;"><a href="#M000093">only_keys?</a></span>
|
154
|
-
<span style="padding-right: 5px;"><a href="#M000104">recursive_merge</a></span>
|
155
|
-
<span style="padding-right: 5px;"><a href="#M000105">recursive_merge!</a></span>
|
156
|
-
<span style="padding-right: 5px;"><a href="#M000084">recursively</a></span>
|
157
|
-
<span style="padding-right: 5px;"><a href="#M000085">recursively!</a></span>
|
158
|
-
<span style="padding-right: 5px;"><a href="#M000131">rekey</a></span>
|
159
|
-
<span style="padding-right: 5px;"><a href="#M000132">rekey!</a></span>
|
160
|
-
<span style="padding-right: 5px;"><a href="#M000127">replace_each</a></span>
|
161
|
-
<span style="padding-right: 5px;"><a href="#M000095">reverse_merge</a></span>
|
162
|
-
<span style="padding-right: 5px;"><a href="#M000096">reverse_merge!</a></span>
|
163
|
-
<span style="padding-right: 5px;"><a href="#M000097">reverse_update</a></span>
|
164
|
-
<span style="padding-right: 5px;"><a href="#M000109">select!</a></span>
|
165
|
-
<span style="padding-right: 5px;"><a href="#M000128">slice</a></span>
|
166
|
-
<span style="padding-right: 5px;"><a href="#M000129">slice!</a></span>
|
167
|
-
<span style="padding-right: 5px;"><a href="#M000123">stringify_keys</a></span>
|
168
|
-
<span style="padding-right: 5px;"><a href="#M000124">stringify_keys!</a></span>
|
169
|
-
<span style="padding-right: 5px;"><a href="#M000119">swap!</a></span>
|
170
|
-
<span style="padding-right: 5px;"><a href="#M000121">symbolize_keys</a></span>
|
171
|
-
<span style="padding-right: 5px;"><a href="#M000122">symbolize_keys!</a></span>
|
172
|
-
<span style="padding-right: 5px;"><a href="#M000075">to_h</a></span>
|
173
|
-
<span style="padding-right: 5px;"><a href="#M000076">to_hash</a></span>
|
174
|
-
<span style="padding-right: 5px;"><a href="#M000106">to_proc</a></span>
|
175
|
-
<span style="padding-right: 5px;"><a href="#M000107">to_proc_with_reponse</a></span>
|
176
|
-
<span style="padding-right: 5px;"><a href="#M000120">to_struct</a></span>
|
177
|
-
<span style="padding-right: 5px;"><a href="#M000098">traverse</a></span>
|
178
|
-
<span style="padding-right: 5px;"><a href="#M000099">traverse!</a></span>
|
179
|
-
<span style="padding-right: 5px;"><a href="#M000133">update_each</a></span>
|
180
|
-
<span style="padding-right: 5px;"><a href="#M000134">update_keys</a></span>
|
181
|
-
<span style="padding-right: 5px;"><a href="#M000081">update_values</a></span>
|
182
|
-
<span style="padding-right: 5px;"><a href="#M000118">weave</a></span>
|
183
|
-
<span style="padding-right: 5px;"><a href="#M000078">zipnew</a></span>
|
184
|
-
<span style="padding-right: 5px;"><a href="#M000100">|</a></span>
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
<div class="sectiontitle">Public Class methods</div>
|
192
|
-
<div class="method">
|
193
|
-
<div class="title">
|
194
|
-
<a name="M000083"></a><b>autonew</b>(*args)
|
195
|
-
</div>
|
196
|
-
<div class="description">
|
197
|
-
<pre>
|
198
|
-
Hash which auto initializes it's children.
|
199
|
-
|
200
|
-
ah = Hash.autonew
|
201
|
-
ah['section one']['param one'] = 4
|
202
|
-
ah['section one']['param two'] = 5
|
203
|
-
ah['section one']['param three'] = 2
|
204
|
-
ah['section one']['param four'] = 3
|
205
|
-
|
206
|
-
p ah
|
207
|
-
# {"section one"=>{"param one"=>4, "param four"=>3, "param three"=>2, "param two"=>5}}
|
208
|
-
|
209
|
-
p ah['section one'].keys
|
210
|
-
# ["param one", "param four", "param three", "param two"]
|
211
|
-
</pre>
|
212
|
-
<p>
|
213
|
-
CREDIT: Trans, Jan Molic
|
214
|
-
</p>
|
215
|
-
</div>
|
216
|
-
<div class="sourcecode">
|
217
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000083_source')" id="l_M000083_source">+</a> ]</p>
|
218
|
-
<div id="M000083_source" class="dyn-source">
|
219
|
-
<pre>
|
220
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/autonew.rb, line 19</span>
|
221
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">autonew</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
222
|
-
<span class="ruby-comment cmt">#new(*args){|a,k| a[k] = self.class::new(*args)}</span>
|
223
|
-
<span class="ruby-identifier">leet</span> = <span class="ruby-identifier">lambda</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">hsh</span>, <span class="ruby-identifier">key</span><span class="ruby-operator">|</span> <span class="ruby-identifier">hsh</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">new</span>( <span class="ruby-operator">&</span><span class="ruby-identifier">leet</span> ) }
|
224
|
-
<span class="ruby-identifier">new</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>,<span class="ruby-operator">&</span><span class="ruby-identifier">leet</span>)
|
225
|
-
<span class="ruby-keyword kw">end</span>
|
226
|
-
</pre>
|
227
|
-
</div>
|
228
|
-
</div>
|
229
|
-
</div>
|
230
|
-
<div class="method">
|
231
|
-
<div class="title">
|
232
|
-
<a name="M000077"></a><b>new_with</b>( {|| ...}
|
233
|
-
</div>
|
234
|
-
<div class="description">
|
235
|
-
<p>
|
236
|
-
Instantiate a new hash with a default value determined by the block.
|
237
|
-
</p>
|
238
|
-
<p>
|
239
|
-
<a href="Hash.html#M000077">Hash.new_with</a> { [] }
|
240
|
-
</p>
|
241
|
-
<p>
|
242
|
-
CREDIT: Pit Capitan
|
243
|
-
</p>
|
244
|
-
</div>
|
245
|
-
<div class="sourcecode">
|
246
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000077_source')" id="l_M000077_source">+</a> ]</p>
|
247
|
-
<div id="M000077_source" class="dyn-source">
|
248
|
-
<pre>
|
249
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/new_with.rb, line 10</span>
|
250
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">new_with</span> <span class="ruby-comment cmt">#:yield:</span>
|
251
|
-
<span class="ruby-identifier">new</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">h</span>, <span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-identifier">h</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-keyword kw">yield</span> }
|
252
|
-
<span class="ruby-keyword kw">end</span>
|
253
|
-
</pre>
|
254
|
-
</div>
|
255
|
-
</div>
|
256
|
-
</div>
|
257
|
-
<div class="method">
|
258
|
-
<div class="title">
|
259
|
-
<a name="M000078"></a><b>zipnew</b>(keys,values)
|
260
|
-
</div>
|
261
|
-
<div class="description">
|
262
|
-
<p>
|
263
|
-
Creates a new hash from two arrays —a keys array and a values array.
|
264
|
-
</p>
|
265
|
-
<pre>
|
266
|
-
Hash.zipnew(["a","b","c"], [1,2,3])
|
267
|
-
#=> { "a"=>1, "b"=>2, "c"=>3 }
|
268
|
-
</pre>
|
269
|
-
<p>
|
270
|
-
CREDIT: Trans, Ara T. Howard
|
271
|
-
</p>
|
272
|
-
</div>
|
273
|
-
<div class="sourcecode">
|
274
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000078_source')" id="l_M000078_source">+</a> ]</p>
|
275
|
-
<div id="M000078_source" class="dyn-source">
|
276
|
-
<pre>
|
277
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/zipnew.rb, line 11</span>
|
278
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">zipnew</span>(<span class="ruby-identifier">keys</span>,<span class="ruby-identifier">values</span>) <span class="ruby-comment cmt"># or some better name</span>
|
279
|
-
<span class="ruby-identifier">h</span> = {}
|
280
|
-
<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">size</span>.<span class="ruby-identifier">times</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-identifier">h</span>[ <span class="ruby-identifier">keys</span>[<span class="ruby-identifier">i</span>] ] = <span class="ruby-identifier">values</span>[<span class="ruby-identifier">i</span>] }
|
281
|
-
<span class="ruby-identifier">h</span>
|
282
|
-
<span class="ruby-keyword kw">end</span>
|
283
|
-
</pre>
|
284
|
-
</div>
|
285
|
-
</div>
|
286
|
-
</div>
|
287
|
-
<div class="sectiontitle">Public Instance methods</div>
|
288
|
-
<div class="method">
|
289
|
-
<div class="title">
|
290
|
-
<a name="M000086"></a><b>&</b>(other)
|
291
|
-
</div>
|
292
|
-
<div class="description">
|
293
|
-
<p>
|
294
|
-
<a href="Hash.html">Hash</a> intersection. Two hashes intersect when their
|
295
|
-
pairs are equal.
|
296
|
-
</p>
|
297
|
-
<pre>
|
298
|
-
{:a=>1,:b=>2} & {:a=>1,:c=>3} #=> {:a=>1}
|
299
|
-
</pre>
|
300
|
-
<p>
|
301
|
-
A hash can also be intersected with an array to intersect keys only.
|
302
|
-
</p>
|
303
|
-
<pre>
|
304
|
-
{:a=>1,:b=>2} & [:a,:c] #=> {:a=>1}
|
305
|
-
</pre>
|
306
|
-
<p>
|
307
|
-
The later form is similar to pairs_at. The differ only in that pairs_at
|
308
|
-
will return a nil value for a key not in the hash, but #& will not.
|
309
|
-
</p>
|
310
|
-
<p>
|
311
|
-
CREDIT: Trans
|
312
|
-
</p>
|
313
|
-
</div>
|
314
|
-
<div class="sourcecode">
|
315
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000086_source')" id="l_M000086_source">+</a> ]</p>
|
316
|
-
<div id="M000086_source" class="dyn-source">
|
317
|
-
<pre>
|
318
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/op_and.rb, line 19</span>
|
319
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-operator">&</span>(<span class="ruby-identifier">other</span>)
|
320
|
-
<span class="ruby-keyword kw">case</span> <span class="ruby-identifier">other</span>
|
321
|
-
<span class="ruby-keyword kw">when</span> <span class="ruby-constant">Array</span>
|
322
|
-
<span class="ruby-identifier">k</span> = (<span class="ruby-identifier">keys</span> <span class="ruby-operator">&</span> <span class="ruby-identifier">other</span>)
|
323
|
-
<span class="ruby-constant">Hash</span>[<span class="ruby-operator">*</span>(<span class="ruby-identifier">k</span>.<span class="ruby-identifier">zip</span>(<span class="ruby-identifier">values_at</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">k</span>)).<span class="ruby-identifier">flatten</span>)]
|
324
|
-
<span class="ruby-keyword kw">else</span>
|
325
|
-
<span class="ruby-identifier">x</span> = (<span class="ruby-identifier">to_a</span> <span class="ruby-operator">&</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">to_a</span>).<span class="ruby-identifier">inject</span>([]) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">a</span>, <span class="ruby-identifier">kv</span><span class="ruby-operator">|</span>
|
326
|
-
<span class="ruby-identifier">a</span>.<span class="ruby-identifier">concat</span> <span class="ruby-identifier">kv</span>; <span class="ruby-identifier">a</span>
|
327
|
-
<span class="ruby-keyword kw">end</span>
|
328
|
-
<span class="ruby-constant">Hash</span>[<span class="ruby-operator">*</span><span class="ruby-identifier">x</span>]
|
329
|
-
<span class="ruby-keyword kw">end</span>
|
330
|
-
<span class="ruby-keyword kw">end</span>
|
331
|
-
</pre>
|
332
|
-
</div>
|
333
|
-
</div>
|
334
|
-
</div>
|
335
|
-
<div class="method">
|
336
|
-
<div class="title">
|
337
|
-
<a name="M000101"></a><b>*</b>(other)
|
338
|
-
</div>
|
339
|
-
<div class="description">
|
340
|
-
<p>
|
341
|
-
Like merge operator ’+’ but merges in reverse order.
|
342
|
-
</p>
|
343
|
-
<pre>
|
344
|
-
h1 = { :a=>1 }
|
345
|
-
h2 = { :a=>2, :b=>3 }
|
346
|
-
|
347
|
-
h1 + h2 #=> { :a=>2, :b=>3 }
|
348
|
-
h1 * h2 #=> { :a=>1, :b=>3 }
|
349
|
-
</pre>
|
350
|
-
<p>
|
351
|
-
CREDIT: Trans
|
352
|
-
</p>
|
353
|
-
</div>
|
354
|
-
<div class="sourcecode">
|
355
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000101_source')" id="l_M000101_source">+</a> ]</p>
|
356
|
-
<div id="M000101_source" class="dyn-source">
|
357
|
-
<pre>
|
358
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/op_mul.rb, line 13</span>
|
359
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-operator">*</span>(<span class="ruby-identifier">other</span>)
|
360
|
-
<span class="ruby-identifier">other</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-keyword kw">self</span>)
|
361
|
-
<span class="ruby-keyword kw">end</span>
|
362
|
-
</pre>
|
363
|
-
</div>
|
364
|
-
</div>
|
365
|
-
</div>
|
366
|
-
<div class="method">
|
367
|
-
<div class="title">
|
368
|
-
<a name="M000130"></a><b>+</b>(other)
|
369
|
-
</div>
|
370
|
-
<div class="description">
|
371
|
-
<p>
|
372
|
-
Operator for merge.
|
373
|
-
</p>
|
374
|
-
<p>
|
375
|
-
CREDIT: Trans
|
376
|
-
</p>
|
377
|
-
</div>
|
378
|
-
<div class="sourcecode">
|
379
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000130_source')" id="l_M000130_source">+</a> ]</p>
|
380
|
-
<div id="M000130_source" class="dyn-source">
|
381
|
-
<pre>
|
382
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/op_add.rb, line 7</span>
|
383
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-operator">+</span>(<span class="ruby-identifier">other</span>)
|
384
|
-
<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">other</span>)
|
385
|
-
<span class="ruby-keyword kw">end</span>
|
386
|
-
</pre>
|
387
|
-
</div>
|
388
|
-
</div>
|
389
|
-
</div>
|
390
|
-
<div class="method">
|
391
|
-
<div class="title">
|
392
|
-
<a name="M000087"></a><b>-</b>(other)
|
393
|
-
</div>
|
394
|
-
<div class="description">
|
395
|
-
<p>
|
396
|
-
Operator for remove hash paris. If another hash is given the pairs are only
|
397
|
-
removed if both key and value are equal. If an array is given then matching
|
398
|
-
keys are removed.
|
399
|
-
</p>
|
400
|
-
<p>
|
401
|
-
CREDIT: Trans
|
402
|
-
</p>
|
403
|
-
</div>
|
404
|
-
<div class="sourcecode">
|
405
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000087_source')" id="l_M000087_source">+</a> ]</p>
|
406
|
-
<div id="M000087_source" class="dyn-source">
|
407
|
-
<pre>
|
408
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/op_sub.rb, line 9</span>
|
409
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-operator">-</span>(<span class="ruby-identifier">other</span>)
|
410
|
-
<span class="ruby-identifier">h</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">dup</span>
|
411
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:to_ary</span>)
|
412
|
-
<span class="ruby-identifier">other</span>.<span class="ruby-identifier">to_ary</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span>
|
413
|
-
<span class="ruby-identifier">h</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">k</span>)
|
414
|
-
<span class="ruby-keyword kw">end</span>
|
415
|
-
<span class="ruby-keyword kw">else</span>
|
416
|
-
<span class="ruby-identifier">other</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
|
417
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">h</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-identifier">k</span>)
|
418
|
-
<span class="ruby-identifier">h</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">k</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">v</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">h</span>[<span class="ruby-identifier">k</span>]
|
419
|
-
<span class="ruby-keyword kw">end</span>
|
420
|
-
<span class="ruby-keyword kw">end</span>
|
421
|
-
<span class="ruby-keyword kw">end</span>
|
422
|
-
<span class="ruby-identifier">h</span>
|
423
|
-
<span class="ruby-keyword kw">end</span>
|
424
|
-
</pre>
|
425
|
-
</div>
|
426
|
-
</div>
|
427
|
-
</div>
|
428
|
-
<div class="method">
|
429
|
-
<div class="title">
|
430
|
-
<a name="M000102"></a><b><<</b>(other)
|
431
|
-
</div>
|
432
|
-
<div class="description">
|
433
|
-
<p>
|
434
|
-
Can be used like update, or passed as two-element [key,value] array.
|
435
|
-
</p>
|
436
|
-
<p>
|
437
|
-
CREDIT: Trans
|
438
|
-
</p>
|
439
|
-
</div>
|
440
|
-
<div class="sourcecode">
|
441
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000102_source')" id="l_M000102_source">+</a> ]</p>
|
442
|
-
<div id="M000102_source" class="dyn-source">
|
443
|
-
<pre>
|
444
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/op_push.rb, line 8</span>
|
445
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-operator"><<</span>(<span class="ruby-identifier">other</span>)
|
446
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:to_ary</span>)
|
447
|
-
<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">store</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">other</span>)
|
448
|
-
<span class="ruby-keyword kw">else</span>
|
449
|
-
<span class="ruby-identifier">update</span>(<span class="ruby-identifier">other</span>)
|
450
|
-
<span class="ruby-keyword kw">end</span>
|
451
|
-
<span class="ruby-keyword kw">self</span>
|
452
|
-
<span class="ruby-keyword kw">end</span>
|
453
|
-
</pre>
|
454
|
-
</div>
|
455
|
-
</div>
|
456
|
-
</div>
|
457
|
-
<div class="method">
|
458
|
-
<div class="title">
|
459
|
-
<a name="M000082"></a><b>alias!</b>(newkey, oldkey)
|
460
|
-
</div>
|
461
|
-
<div class="description">
|
462
|
-
<p>
|
463
|
-
Modifies the receiving <a href="Hash.html">Hash</a> so that the value
|
464
|
-
previously referred to by <em>oldkey</em> is also referenced by
|
465
|
-
<em>newkey</em>; <em>oldkey</em> is retained in the <a
|
466
|
-
href="Hash.html">Hash</a>. If <em>oldkey</em> does not exist as a key in
|
467
|
-
the <a href="Hash.html">Hash</a>, no change is effected.
|
468
|
-
</p>
|
469
|
-
<p>
|
470
|
-
Returns a reference to the <a href="Hash.html">Hash</a>.
|
471
|
-
</p>
|
472
|
-
<pre>
|
473
|
-
foo = { :name=>'Gavin', 'wife'=>:Lisa }
|
474
|
-
foo.alias!('name',:name) => { :name=>'Gavin', 'name'=>'Gavin', 'wife'=>:Lisa }
|
475
|
-
|
476
|
-
foo = { :name=>'Gavin', 'wife'=>:Lisa }
|
477
|
-
foo.alias!('spouse','wife') => { :name=>'Gavin', 'wife'=>:Lisa, 'spouse'=>:Lisa }
|
478
|
-
|
479
|
-
foo = { :name=>'Gavin', 'wife'=>:Lisa }
|
480
|
-
foo.alias!('bar','foo') => { :name=>'Gavin', 'wife'=>:Lisa }
|
481
|
-
</pre>
|
482
|
-
<p>
|
483
|
-
Note that if the <em>oldkey</em> is reassigned, the reference will no
|
484
|
-
longer exist, and the <em>newkey</em> will remain as it was.
|
485
|
-
</p>
|
486
|
-
<p>
|
487
|
-
CREDIT: Gavin Sinclair
|
488
|
-
</p>
|
489
|
-
<p>
|
490
|
-
TODO: Rename to aliaskey or something else.
|
491
|
-
</p>
|
492
|
-
</div>
|
493
|
-
<div class="sourcecode">
|
494
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000082_source')" id="l_M000082_source">+</a> ]</p>
|
495
|
-
<div id="M000082_source" class="dyn-source">
|
496
|
-
<pre>
|
497
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/alias.rb, line 25</span>
|
498
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">alias!</span>(<span class="ruby-identifier">newkey</span>, <span class="ruby-identifier">oldkey</span>)
|
499
|
-
<span class="ruby-keyword kw">self</span>[<span class="ruby-identifier">newkey</span>] = <span class="ruby-keyword kw">self</span>[<span class="ruby-identifier">oldkey</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">oldkey</span>)
|
500
|
-
<span class="ruby-keyword kw">self</span>
|
501
|
-
<span class="ruby-keyword kw">end</span>
|
502
|
-
</pre>
|
503
|
-
</div>
|
504
|
-
</div>
|
505
|
-
</div>
|
506
|
-
<div class="method">
|
507
|
-
<div class="title">
|
508
|
-
<a name="M000135"></a><b>argumentize</b>(args_field=nil)
|
509
|
-
</div>
|
510
|
-
<div class="description">
|
511
|
-
<p>
|
512
|
-
Turn a hash into arguments.
|
513
|
-
</p>
|
514
|
-
<pre>
|
515
|
-
h = { :list => [1,2], :base => "HI" }
|
516
|
-
h.argumentize #=> [ [], { :list => [1,2], :base => "HI" } ]
|
517
|
-
h.argumentize(:list) #=> [ [1,2], { :base => "HI" } ]
|
518
|
-
h.argumentize(:base) #=> [ ["HI"], { :list => [1,2] } ]
|
519
|
-
</pre>
|
520
|
-
</div>
|
521
|
-
<div class="sourcecode">
|
522
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000135_source')" id="l_M000135_source">+</a> ]</p>
|
523
|
-
<div id="M000135_source" class="dyn-source">
|
524
|
-
<pre>
|
525
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/argumentize.rb, line 10</span>
|
526
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">argumentize</span>(<span class="ruby-identifier">args_field</span>=<span class="ruby-keyword kw">nil</span>)
|
527
|
-
<span class="ruby-identifier">config</span> = <span class="ruby-identifier">dup</span>
|
528
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args_field</span>
|
529
|
-
<span class="ruby-identifier">args</span> = [<span class="ruby-identifier">config</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">args_field</span>)].<span class="ruby-identifier">flatten</span>.<span class="ruby-identifier">compact</span>
|
530
|
-
<span class="ruby-keyword kw">else</span>
|
531
|
-
<span class="ruby-identifier">args</span> = []
|
532
|
-
<span class="ruby-keyword kw">end</span>
|
533
|
-
<span class="ruby-identifier">args</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">config</span>
|
534
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">args</span>
|
535
|
-
<span class="ruby-keyword kw">end</span>
|
536
|
-
</pre>
|
537
|
-
</div>
|
538
|
-
</div>
|
539
|
-
</div>
|
540
|
-
<div class="method">
|
541
|
-
<div class="title">
|
542
|
-
<a name="M000113"></a><b>collate</b>(other_hash)
|
543
|
-
</div>
|
544
|
-
<div class="description">
|
545
|
-
<p>
|
546
|
-
Merge the values of this hash with those from another, setting all values
|
547
|
-
to be arrays representing the values from both hashes.
|
548
|
-
</p>
|
549
|
-
<pre>
|
550
|
-
{ :a=>1, :b=>2 }.collate :a=>3, :b=>4, :c=>5
|
551
|
-
#=> { :a=>[1,3], :b=>[2,4], :c=>[5] }
|
552
|
-
</pre>
|
553
|
-
<p>
|
554
|
-
CREDIT: Tilo Sloboda CREDIT: Gavin Kistner (Phrogz)
|
555
|
-
</p>
|
556
|
-
</div>
|
557
|
-
<div class="sourcecode">
|
558
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000113_source')" id="l_M000113_source">+</a> ]</p>
|
559
|
-
<div id="M000113_source" class="dyn-source">
|
560
|
-
<pre>
|
561
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/collate.rb, line 12</span>
|
562
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">collate</span>(<span class="ruby-identifier">other_hash</span>)
|
563
|
-
<span class="ruby-identifier">h</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>
|
564
|
-
<span class="ruby-comment cmt"># Prepare, ensuring every existing key is already an Array</span>
|
565
|
-
<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
|
566
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Array</span>)
|
567
|
-
<span class="ruby-identifier">h</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">value</span>
|
568
|
-
<span class="ruby-keyword kw">else</span>
|
569
|
-
<span class="ruby-identifier">h</span>[<span class="ruby-identifier">key</span>] = [<span class="ruby-identifier">value</span>]
|
570
|
-
<span class="ruby-keyword kw">end</span>
|
571
|
-
<span class="ruby-keyword kw">end</span>
|
572
|
-
<span class="ruby-comment cmt"># Collate with values from other_hash</span>
|
573
|
-
<span class="ruby-identifier">other_hash</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
|
574
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">h</span>[<span class="ruby-identifier">key</span>]
|
575
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Array</span>)
|
576
|
-
<span class="ruby-identifier">h</span>[<span class="ruby-identifier">key</span>].<span class="ruby-identifier">concat</span>(<span class="ruby-identifier">value</span>)
|
577
|
-
<span class="ruby-keyword kw">else</span>
|
578
|
-
<span class="ruby-identifier">h</span>[<span class="ruby-identifier">key</span>] <span class="ruby-operator"><<</span> <span class="ruby-identifier">value</span>
|
579
|
-
<span class="ruby-keyword kw">end</span>
|
580
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Array</span>)
|
581
|
-
<span class="ruby-identifier">h</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">value</span>
|
582
|
-
<span class="ruby-keyword kw">else</span>
|
583
|
-
<span class="ruby-identifier">h</span>[<span class="ruby-identifier">key</span>] = [<span class="ruby-identifier">value</span>]
|
584
|
-
<span class="ruby-keyword kw">end</span>
|
585
|
-
<span class="ruby-keyword kw">end</span>
|
586
|
-
<span class="ruby-comment cmt">#each{ |key, value| value.uniq! } if options[ :uniq ]</span>
|
587
|
-
<span class="ruby-identifier">h</span>
|
588
|
-
<span class="ruby-keyword kw">end</span>
|
589
|
-
</pre>
|
590
|
-
</div>
|
591
|
-
</div>
|
592
|
-
</div>
|
593
|
-
<div class="method">
|
594
|
-
<div class="title">
|
595
|
-
<a name="M000114"></a><b>collate!</b>(other_hash)
|
596
|
-
</div>
|
597
|
-
<div class="description">
|
598
|
-
<p>
|
599
|
-
The same as <a href="Hash.html#M000113">collate</a>, but modifies the
|
600
|
-
receiver in place.
|
601
|
-
</p>
|
602
|
-
</div>
|
603
|
-
<div class="sourcecode">
|
604
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000114_source')" id="l_M000114_source">+</a> ]</p>
|
605
|
-
<div id="M000114_source" class="dyn-source">
|
606
|
-
<pre>
|
607
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/collate.rb, line 42</span>
|
608
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">collate!</span>(<span class="ruby-identifier">other_hash</span>)
|
609
|
-
<span class="ruby-identifier">result</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">collate</span>(<span class="ruby-identifier">other_hash</span>)
|
610
|
-
<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">replace</span>(<span class="ruby-identifier">result</span>)
|
611
|
-
<span class="ruby-keyword kw">end</span>
|
612
|
-
</pre>
|
613
|
-
</div>
|
614
|
-
</div>
|
615
|
-
</div>
|
616
|
-
<div class="method">
|
617
|
-
<div class="title">
|
618
|
-
<a name="M000080"></a><b>dearray_singular_values</b>()
|
619
|
-
</div>
|
620
|
-
<div class="description">
|
621
|
-
<p>
|
622
|
-
Any array values with one or no elements will be set to the element or nil.
|
623
|
-
</p>
|
624
|
-
<pre>
|
625
|
-
h = { :a=>[1], :b=>[1,2], :c=>3, :d=>[] }
|
626
|
-
h.dearray_singular_values #=> { :a=>1, :b=>[1,2], :c=>3, :d=>nil }
|
627
|
-
</pre>
|
628
|
-
<p>
|
629
|
-
CREDIT: Trans
|
630
|
-
</p>
|
631
|
-
</div>
|
632
|
-
<div class="sourcecode">
|
633
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000080_source')" id="l_M000080_source">+</a> ]</p>
|
634
|
-
<div id="M000080_source" class="dyn-source">
|
635
|
-
<pre>
|
636
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/dearray_values.rb, line 32</span>
|
637
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">dearray_singular_values</span>
|
638
|
-
<span class="ruby-identifier">h</span> = {}
|
639
|
-
<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
|
640
|
-
<span class="ruby-keyword kw">case</span> <span class="ruby-identifier">v</span>
|
641
|
-
<span class="ruby-keyword kw">when</span> <span class="ruby-constant">Array</span>
|
642
|
-
<span class="ruby-identifier">h</span>[<span class="ruby-identifier">k</span>] = (<span class="ruby-identifier">v</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator"><</span> <span class="ruby-value">2</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">v</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">:</span> <span class="ruby-identifier">v</span>
|
643
|
-
<span class="ruby-keyword kw">else</span>
|
644
|
-
<span class="ruby-identifier">h</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">v</span>
|
645
|
-
<span class="ruby-keyword kw">end</span>
|
646
|
-
<span class="ruby-keyword kw">end</span>
|
647
|
-
<span class="ruby-identifier">h</span>
|
648
|
-
<span class="ruby-keyword kw">end</span>
|
649
|
-
</pre>
|
650
|
-
</div>
|
651
|
-
</div>
|
652
|
-
</div>
|
653
|
-
<div class="method">
|
654
|
-
<div class="title">
|
655
|
-
<a name="M000079"></a><b>dearray_values</b>(index=0)
|
656
|
-
</div>
|
657
|
-
<div class="description">
|
658
|
-
<p>
|
659
|
-
Any array values with be replaced with the first element of the array.
|
660
|
-
Arrays with no elements will be set to nil.
|
661
|
-
</p>
|
662
|
-
<pre>
|
663
|
-
h = { :a=>[1], :b=>[1,2], :c=>3, :d=>[] }
|
664
|
-
h.dearray_values #=> { :a=>1, :b=>1, :c=>3, :d=>nil }
|
665
|
-
</pre>
|
666
|
-
<p>
|
667
|
-
CREDIT: Trans
|
668
|
-
</p>
|
669
|
-
</div>
|
670
|
-
<div class="sourcecode">
|
671
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000079_source')" id="l_M000079_source">+</a> ]</p>
|
672
|
-
<div id="M000079_source" class="dyn-source">
|
673
|
-
<pre>
|
674
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/dearray_values.rb, line 11</span>
|
675
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">dearray_values</span>(<span class="ruby-identifier">index</span>=<span class="ruby-value">0</span>)
|
676
|
-
<span class="ruby-identifier">h</span> = {}
|
677
|
-
<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
|
678
|
-
<span class="ruby-keyword kw">case</span> <span class="ruby-identifier">v</span>
|
679
|
-
<span class="ruby-keyword kw">when</span> <span class="ruby-constant">Array</span>
|
680
|
-
<span class="ruby-identifier">h</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">v</span>[<span class="ruby-identifier">index</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">v</span>[<span class="ruby-value">-1</span>]
|
681
|
-
<span class="ruby-keyword kw">else</span>
|
682
|
-
<span class="ruby-identifier">h</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">v</span>
|
683
|
-
<span class="ruby-keyword kw">end</span>
|
684
|
-
<span class="ruby-keyword kw">end</span>
|
685
|
-
<span class="ruby-identifier">h</span>
|
686
|
-
<span class="ruby-keyword kw">end</span>
|
687
|
-
</pre>
|
688
|
-
</div>
|
689
|
-
</div>
|
690
|
-
</div>
|
691
|
-
<div class="method">
|
692
|
-
<div class="title">
|
693
|
-
<a name="M000115"></a><b>delete_unless</b>( {|| ...}
|
694
|
-
</div>
|
695
|
-
<div class="description">
|
696
|
-
<p>
|
697
|
-
Inverse of delete_if.
|
698
|
-
</p>
|
699
|
-
<p>
|
700
|
-
CREDIT: Daniel Schierbeck
|
701
|
-
</p>
|
702
|
-
</div>
|
703
|
-
<div class="sourcecode">
|
704
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000115_source')" id="l_M000115_source">+</a> ]</p>
|
705
|
-
<div id="M000115_source" class="dyn-source">
|
706
|
-
<pre>
|
707
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/delete.rb, line 11</span>
|
708
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete_unless</span> <span class="ruby-comment cmt">#:yield:</span>
|
709
|
-
<span class="ruby-identifier">delete_if</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-operator">!</span> <span class="ruby-keyword kw">yield</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span>) }
|
710
|
-
<span class="ruby-keyword kw">end</span>
|
711
|
-
</pre>
|
712
|
-
</div>
|
713
|
-
</div>
|
714
|
-
</div>
|
715
|
-
<div class="method">
|
716
|
-
<div class="title">
|
717
|
-
<a name="M000116"></a><b>delete_values</b>(*values)
|
718
|
-
</div>
|
719
|
-
<div class="description">
|
720
|
-
<p>
|
721
|
-
Minor modification to Ruby‘s Hash#delete method allowing it to take
|
722
|
-
multiple keys.
|
723
|
-
</p>
|
724
|
-
<pre>
|
725
|
-
hsh = { :a => 1, :b => 2 }
|
726
|
-
hsh.delete_values(1)
|
727
|
-
hsh #=> { :b => 2 }
|
728
|
-
</pre>
|
729
|
-
<p>
|
730
|
-
CREDIT: Daniel Schierbeck
|
731
|
-
</p>
|
732
|
-
</div>
|
733
|
-
<div class="sourcecode">
|
734
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000116_source')" id="l_M000116_source">+</a> ]</p>
|
735
|
-
<div id="M000116_source" class="dyn-source">
|
736
|
-
<pre>
|
737
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/delete.rb, line 24</span>
|
738
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete_values</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">values</span>)
|
739
|
-
<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">map</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span> <span class="ruby-identifier">delete</span>(<span class="ruby-identifier">key</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">values</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">fetch</span>(<span class="ruby-identifier">key</span>)) }
|
740
|
-
<span class="ruby-keyword kw">end</span>
|
741
|
-
</pre>
|
742
|
-
</div>
|
743
|
-
</div>
|
744
|
-
</div>
|
745
|
-
<div class="method">
|
746
|
-
<div class="title">
|
747
|
-
<a name="M000117"></a><b>delete_values_at</b>(*keys, &yld)
|
748
|
-
</div>
|
749
|
-
<div class="description">
|
750
|
-
<p>
|
751
|
-
Minor modification to Ruby‘s Hash#delete method allowing it to take
|
752
|
-
multiple keys.
|
753
|
-
</p>
|
754
|
-
<p>
|
755
|
-
This works niely with hash#[] and <a href="Hash.html">Hash</a>#[]= facets.
|
756
|
-
</p>
|
757
|
-
<pre>
|
758
|
-
hsh[:a, :b, :c] = 1, 2, 3
|
759
|
-
|
760
|
-
a, b, c = hsh.delete_values_at(:a, :b, :c)
|
761
|
-
|
762
|
-
[a, b, c] #=> [1, 2, 3]
|
763
|
-
hsh #=> {}
|
764
|
-
</pre>
|
765
|
-
<p>
|
766
|
-
CREDIT: Daniel Schierbeck
|
767
|
-
</p>
|
768
|
-
</div>
|
769
|
-
<div class="sourcecode">
|
770
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000117_source')" id="l_M000117_source">+</a> ]</p>
|
771
|
-
<div id="M000117_source" class="dyn-source">
|
772
|
-
<pre>
|
773
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/delete.rb, line 42</span>
|
774
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete_values_at</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">keys</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">yld</span>)
|
775
|
-
<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">map</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span> <span class="ruby-identifier">delete</span>(<span class="ruby-identifier">key</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">yld</span>) }
|
776
|
-
<span class="ruby-keyword kw">end</span>
|
777
|
-
</pre>
|
778
|
-
</div>
|
779
|
-
</div>
|
780
|
-
</div>
|
781
|
-
<div class="method">
|
782
|
-
<div class="title">
|
783
|
-
<a name="M000110"></a><b>diff</b>(hash)
|
784
|
-
</div>
|
785
|
-
<div class="description">
|
786
|
-
<p>
|
787
|
-
Difference comparison of two hashes.
|
788
|
-
</p>
|
789
|
-
</div>
|
790
|
-
<div class="sourcecode">
|
791
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000110_source')" id="l_M000110_source">+</a> ]</p>
|
792
|
-
<div id="M000110_source" class="dyn-source">
|
793
|
-
<pre>
|
794
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/diff.rb, line 5</span>
|
795
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">diff</span>(<span class="ruby-identifier">hash</span>)
|
796
|
-
<span class="ruby-identifier">h1</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">dup</span>.<span class="ruby-identifier">delete_if</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">hash</span>[<span class="ruby-identifier">k</span>] <span class="ruby-operator">==</span> <span class="ruby-identifier">v</span> }
|
797
|
-
<span class="ruby-identifier">h2</span> = <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">dup</span>.<span class="ruby-identifier">delete_if</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">k</span>) }
|
798
|
-
<span class="ruby-identifier">h1</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">h2</span>)
|
799
|
-
<span class="ruby-keyword kw">end</span>
|
800
|
-
</pre>
|
801
|
-
</div>
|
802
|
-
</div>
|
803
|
-
</div>
|
804
|
-
<div class="method">
|
805
|
-
<div class="title">
|
806
|
-
<a name="M000094"></a><b>each_with_key</b>( &yld )
|
807
|
-
</div>
|
808
|
-
<div class="description">
|
809
|
-
<p>
|
810
|
-
Each with key is like each_pair but reverses the order the parameters to
|
811
|
-
[value,key] instead of [key,value].
|
812
|
-
</p>
|
813
|
-
<p>
|
814
|
-
CREDIT: Trans
|
815
|
-
</p>
|
816
|
-
</div>
|
817
|
-
<div class="sourcecode">
|
818
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000094_source')" id="l_M000094_source">+</a> ]</p>
|
819
|
-
<div id="M000094_source" class="dyn-source">
|
820
|
-
<pre>
|
821
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/keys.rb, line 40</span>
|
822
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">each_with_key</span>( <span class="ruby-operator">&</span><span class="ruby-identifier">yld</span> )
|
823
|
-
<span class="ruby-identifier">each_pair</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">yld</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">v</span>,<span class="ruby-identifier">k</span>) }
|
824
|
-
<span class="ruby-keyword kw">end</span>
|
825
|
-
</pre>
|
826
|
-
</div>
|
827
|
-
</div>
|
828
|
-
</div>
|
829
|
-
<div class="method">
|
830
|
-
<div class="title">
|
831
|
-
<a name="M000088"></a><b>except</b>(*less_keys)
|
832
|
-
</div>
|
833
|
-
<div class="description">
|
834
|
-
<p>
|
835
|
-
Returns a new hash less the given keys.
|
836
|
-
</p>
|
837
|
-
</div>
|
838
|
-
<div class="sourcecode">
|
839
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000088_source')" id="l_M000088_source">+</a> ]</p>
|
840
|
-
<div id="M000088_source" class="dyn-source">
|
841
|
-
<pre>
|
842
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/except.rb, line 5</span>
|
843
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">except</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">less_keys</span>)
|
844
|
-
<span class="ruby-identifier">slice</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">keys</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">less_keys</span>)
|
845
|
-
<span class="ruby-keyword kw">end</span>
|
846
|
-
</pre>
|
847
|
-
</div>
|
848
|
-
</div>
|
849
|
-
</div>
|
850
|
-
<div class="method">
|
851
|
-
<div class="title">
|
852
|
-
<a name="M000089"></a><b>except!</b>(*less_keys)
|
853
|
-
</div>
|
854
|
-
<div class="description">
|
855
|
-
<p>
|
856
|
-
Replaces hash with new hash less the given keys. This returns the hash of
|
857
|
-
keys removed.
|
858
|
-
</p>
|
859
|
-
<pre>
|
860
|
-
h = {:a=>1, :b=>2, :c=>3}
|
861
|
-
h.except!(:a) #=> {:a=>1}
|
862
|
-
h #=> {:b=>2,:c=>3}
|
863
|
-
</pre>
|
864
|
-
</div>
|
865
|
-
<div class="sourcecode">
|
866
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000089_source')" id="l_M000089_source">+</a> ]</p>
|
867
|
-
<div id="M000089_source" class="dyn-source">
|
868
|
-
<pre>
|
869
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/except.rb, line 18</span>
|
870
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">except!</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">less_keys</span>)
|
871
|
-
<span class="ruby-identifier">removed</span> = <span class="ruby-identifier">slice</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">less_keys</span>)
|
872
|
-
<span class="ruby-identifier">replace</span>(<span class="ruby-identifier">except</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">less_keys</span>))
|
873
|
-
<span class="ruby-identifier">removed</span>
|
874
|
-
<span class="ruby-keyword kw">end</span>
|
875
|
-
</pre>
|
876
|
-
</div>
|
877
|
-
</div>
|
878
|
-
</div>
|
879
|
-
<div class="method">
|
880
|
-
<div class="title">
|
881
|
-
<a name="M000112"></a><b>graph!</b>(&yld)
|
882
|
-
</div>
|
883
|
-
<div class="description">
|
884
|
-
<p>
|
885
|
-
Alias for mash!
|
886
|
-
</p>
|
887
|
-
</div>
|
888
|
-
</div>
|
889
|
-
<div class="method">
|
890
|
-
<div class="title">
|
891
|
-
<a name="M000126"></a><b>group_by_value</b>()
|
892
|
-
</div>
|
893
|
-
<div class="description">
|
894
|
-
<p>
|
895
|
-
Like group_by, but allows hash values to be grouped with weeding out the
|
896
|
-
keys.
|
897
|
-
</p>
|
898
|
-
<pre>
|
899
|
-
Example:
|
900
|
-
|
901
|
-
birthdays = {...} # Maps each person to his/her birthday.
|
902
|
-
</pre>
|
903
|
-
<p>
|
904
|
-
Now I want to have the list of people that have their birthday on a
|
905
|
-
specific date. This can be done by creating a hash first, using group_by:
|
906
|
-
</p>
|
907
|
-
<pre>
|
908
|
-
birthdays.group_by{|person, birthday| birthday}
|
909
|
-
</pre>
|
910
|
-
<p>
|
911
|
-
This returns:
|
912
|
-
</p>
|
913
|
-
<p>
|
914
|
-
{date=>[[person1, date], [person2, date], [person3, date]]}
|
915
|
-
</p>
|
916
|
-
<p>
|
917
|
-
… which is a bit inconvient. Too many dates. I would rather like to
|
918
|
-
have:
|
919
|
-
</p>
|
920
|
-
<pre>
|
921
|
-
{date=>[person1, person2, person3]]}
|
922
|
-
</pre>
|
923
|
-
<p>
|
924
|
-
This can be achieved by:
|
925
|
-
</p>
|
926
|
-
<pre>
|
927
|
-
birthdays.inject!({}){|h, (person, date)| (h[date] ||= []) << person}
|
928
|
-
</pre>
|
929
|
-
<p>
|
930
|
-
I‘ve used this pattern just once too often, so I moved the code to <a
|
931
|
-
href="Hash.html">Hash</a> (and <a href="Enumerable.html">Enumerable</a>,
|
932
|
-
for associative arrays). Here‘s the cleaner code:
|
933
|
-
</p>
|
934
|
-
<p>
|
935
|
-
birthdays.group_by_value
|
936
|
-
</p>
|
937
|
-
<pre>
|
938
|
-
h = {"A"=>1, "B"=>1, "C"=>1, "D"=>2, "E"=>2, "F"=>2, "G"=>3, "H"=>3, "I"=>3}
|
939
|
-
|
940
|
-
h.group_by{|k, v| v} # ==> {1=>[["A", 1], ["B", 1], ["C", 1]], 2=>[["D", 2], ["E", 2], ["F", 2]], 3=>[["G", 3], ["H", 3], ["I", 3]]}
|
941
|
-
h.group_by_value # ==> {1=>["A", "B", "C"], 2=>["D", "E", "F"], 3=>["G", "H", "I"]}
|
942
|
-
h.sort.group_by_value # ==> [[1, ["A", "B", "C"]], [2, ["D", "E", "F"]], [3, ["G", "H", "I"]]]
|
943
|
-
</pre>
|
944
|
-
<p>
|
945
|
-
CREDIT: Erik Veenstra
|
946
|
-
</p>
|
947
|
-
</div>
|
948
|
-
<div class="sourcecode">
|
949
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000126_source')" id="l_M000126_source">+</a> ]</p>
|
950
|
-
<div id="M000126_source" class="dyn-source">
|
951
|
-
<pre>
|
952
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/group_by_value.rb, line 42</span>
|
953
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">group_by_value</span>
|
954
|
-
<span class="ruby-identifier">res</span> = {}
|
955
|
-
<span class="ruby-identifier">each</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span><span class="ruby-operator">|</span> (<span class="ruby-identifier">res</span>[<span class="ruby-identifier">v</span>] <span class="ruby-operator">||=</span> []) <span class="ruby-operator"><<</span> <span class="ruby-identifier">k</span>}
|
956
|
-
<span class="ruby-identifier">res</span>
|
957
|
-
<span class="ruby-keyword kw">end</span>
|
958
|
-
</pre>
|
959
|
-
</div>
|
960
|
-
</div>
|
961
|
-
</div>
|
962
|
-
<div class="method">
|
963
|
-
<div class="title">
|
964
|
-
<a name="M000090"></a><b>has_keys?</b>(*check_keys)
|
965
|
-
</div>
|
966
|
-
<div class="description">
|
967
|
-
<p>
|
968
|
-
Returns true or false whether the hash contains the given keys.
|
969
|
-
</p>
|
970
|
-
<pre>
|
971
|
-
h = { :a => 1, :b => 2 }
|
972
|
-
h.has_keys?( :a ) #=> true
|
973
|
-
h.has_keys?( :c ) #=> false
|
974
|
-
</pre>
|
975
|
-
<p>
|
976
|
-
CREDIT: Trans
|
977
|
-
</p>
|
978
|
-
</div>
|
979
|
-
<div class="aka">
|
980
|
-
This method is also aliased as
|
981
|
-
<a href="Hash.html#M000091">keys?</a>
|
982
|
-
</div>
|
983
|
-
<div class="sourcecode">
|
984
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000090_source')" id="l_M000090_source">+</a> ]</p>
|
985
|
-
<div id="M000090_source" class="dyn-source">
|
986
|
-
<pre>
|
987
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/keys.rb, line 12</span>
|
988
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">has_keys?</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">check_keys</span>)
|
989
|
-
<span class="ruby-identifier">unknown_keys</span> = <span class="ruby-identifier">check_keys</span> <span class="ruby-operator">-</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">keys</span>
|
990
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">unknown_keys</span>.<span class="ruby-identifier">empty?</span>
|
991
|
-
<span class="ruby-keyword kw">end</span>
|
992
|
-
</pre>
|
993
|
-
</div>
|
994
|
-
</div>
|
995
|
-
</div>
|
996
|
-
<div class="method">
|
997
|
-
<div class="title">
|
998
|
-
<a name="M000092"></a><b>has_only_keys?</b>(*check_keys)
|
999
|
-
</div>
|
1000
|
-
<div class="description">
|
1001
|
-
<p>
|
1002
|
-
Returns true if the hash contains <em>only</em> the given keys, otherwise
|
1003
|
-
false.
|
1004
|
-
</p>
|
1005
|
-
<pre>
|
1006
|
-
h = { :a => 1, :b => 2 }
|
1007
|
-
h.has_only_keys?( :a, :b ) #=> true
|
1008
|
-
h.has_only_keys?( :a ) #=> false
|
1009
|
-
</pre>
|
1010
|
-
<p>
|
1011
|
-
CREDIT: Trans
|
1012
|
-
</p>
|
1013
|
-
</div>
|
1014
|
-
<div class="aka">
|
1015
|
-
This method is also aliased as
|
1016
|
-
<a href="Hash.html#M000093">only_keys?</a>
|
1017
|
-
</div>
|
1018
|
-
<div class="sourcecode">
|
1019
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000092_source')" id="l_M000092_source">+</a> ]</p>
|
1020
|
-
<div id="M000092_source" class="dyn-source">
|
1021
|
-
<pre>
|
1022
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/keys.rb, line 28</span>
|
1023
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">has_only_keys?</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">check_keys</span>)
|
1024
|
-
<span class="ruby-identifier">unknown_keys</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">keys</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">check_keys</span>
|
1025
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">unknown_keys</span>.<span class="ruby-identifier">empty?</span>
|
1026
|
-
<span class="ruby-keyword kw">end</span>
|
1027
|
-
</pre>
|
1028
|
-
</div>
|
1029
|
-
</div>
|
1030
|
-
</div>
|
1031
|
-
<div class="method">
|
1032
|
-
<div class="title">
|
1033
|
-
<a name="M000108"></a><b>insert</b>(name, value)
|
1034
|
-
</div>
|
1035
|
-
<div class="description">
|
1036
|
-
<p>
|
1037
|
-
As with store but only if the key isn‘t already in the hash.
|
1038
|
-
</p>
|
1039
|
-
<p>
|
1040
|
-
TODO: Would store? be a better name?
|
1041
|
-
</p>
|
1042
|
-
<p>
|
1043
|
-
CREDIT: Trans
|
1044
|
-
</p>
|
1045
|
-
</div>
|
1046
|
-
<div class="sourcecode">
|
1047
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000108_source')" id="l_M000108_source">+</a> ]</p>
|
1048
|
-
<div id="M000108_source" class="dyn-source">
|
1049
|
-
<pre>
|
1050
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/insert.rb, line 10</span>
|
1051
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">insert</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span>)
|
1052
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">key?</span>(<span class="ruby-identifier">name</span>)
|
1053
|
-
<span class="ruby-keyword kw">false</span>
|
1054
|
-
<span class="ruby-keyword kw">else</span>
|
1055
|
-
<span class="ruby-identifier">store</span>(<span class="ruby-identifier">name</span>,<span class="ruby-identifier">value</span>)
|
1056
|
-
<span class="ruby-keyword kw">true</span>
|
1057
|
-
<span class="ruby-keyword kw">end</span>
|
1058
|
-
<span class="ruby-keyword kw">end</span>
|
1059
|
-
</pre>
|
1060
|
-
</div>
|
1061
|
-
</div>
|
1062
|
-
</div>
|
1063
|
-
<div class="method">
|
1064
|
-
<div class="title">
|
1065
|
-
<a name="M000103"></a><b>inverse</b>()
|
1066
|
-
</div>
|
1067
|
-
<div class="description">
|
1068
|
-
<p>
|
1069
|
-
Create a "true" <a href="Hash.html#M000103">inverse</a> hash by
|
1070
|
-
storing mutliple values in Arrays.
|
1071
|
-
</p>
|
1072
|
-
<pre>
|
1073
|
-
h = {"a"=>3, "b"=>3, "c"=>3, "d"=>2, "e"=>9, "f"=>3, "g"=>9}
|
1074
|
-
|
1075
|
-
h.invert #=> {2=>"d", 3=>"f", 9=>"g"}
|
1076
|
-
h.inverse #=> {2=>"d", 3=>["f", "c", "b", "a"], 9=>["g", "e"]}
|
1077
|
-
h.inverse.inverse #=> {"a"=>3, "b"=>3, "c"=>3, "d"=>2, "e"=>9, "f"=>3, "g"=>9}
|
1078
|
-
h.inverse.inverse == h #=> true
|
1079
|
-
</pre>
|
1080
|
-
<p>
|
1081
|
-
CREDIT: Tilo Sloboda
|
1082
|
-
</p>
|
1083
|
-
</div>
|
1084
|
-
<div class="sourcecode">
|
1085
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000103_source')" id="l_M000103_source">+</a> ]</p>
|
1086
|
-
<div id="M000103_source" class="dyn-source">
|
1087
|
-
<pre>
|
1088
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/inverse.rb, line 14</span>
|
1089
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">inverse</span>
|
1090
|
-
<span class="ruby-identifier">i</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>
|
1091
|
-
<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">each_pair</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
|
1092
|
-
<span class="ruby-keyword kw">if</span> (<span class="ruby-constant">Array</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">v</span>)
|
1093
|
-
<span class="ruby-identifier">v</span>.<span class="ruby-identifier">each</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span> <span class="ruby-identifier">i</span>[<span class="ruby-identifier">x</span>] = ( <span class="ruby-identifier">i</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">x</span>) <span class="ruby-operator">?</span> [<span class="ruby-identifier">k</span>,<span class="ruby-identifier">i</span>[<span class="ruby-identifier">x</span>]].<span class="ruby-identifier">flatten</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">k</span> ) }
|
1094
|
-
<span class="ruby-keyword kw">else</span>
|
1095
|
-
<span class="ruby-identifier">i</span>[<span class="ruby-identifier">v</span>] = ( <span class="ruby-identifier">i</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">v</span>) <span class="ruby-operator">?</span> [<span class="ruby-identifier">k</span>,<span class="ruby-identifier">i</span>[<span class="ruby-identifier">v</span>]].<span class="ruby-identifier">flatten</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">k</span> )
|
1096
|
-
<span class="ruby-keyword kw">end</span>
|
1097
|
-
}
|
1098
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">i</span>
|
1099
|
-
<span class="ruby-keyword kw">end</span>
|
1100
|
-
</pre>
|
1101
|
-
</div>
|
1102
|
-
</div>
|
1103
|
-
</div>
|
1104
|
-
<div class="method">
|
1105
|
-
<div class="title">
|
1106
|
-
<a name="M000125"></a><b>join</b>(pair_divider='', elem_divider='')
|
1107
|
-
</div>
|
1108
|
-
<div class="description">
|
1109
|
-
<p>
|
1110
|
-
Like Array#join but specialized to <a href="Hash.html">Hash</a>.
|
1111
|
-
</p>
|
1112
|
-
<p>
|
1113
|
-
CREDIT: Mauricio Fernandez
|
1114
|
-
</p>
|
1115
|
-
</div>
|
1116
|
-
<div class="sourcecode">
|
1117
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000125_source')" id="l_M000125_source">+</a> ]</p>
|
1118
|
-
<div id="M000125_source" class="dyn-source">
|
1119
|
-
<pre>
|
1120
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/join.rb, line 7</span>
|
1121
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">join</span>(<span class="ruby-identifier">pair_divider</span>=<span class="ruby-value str">''</span>, <span class="ruby-identifier">elem_divider</span>=<span class="ruby-value str">''</span>)
|
1122
|
-
<span class="ruby-identifier">s</span> = []
|
1123
|
-
<span class="ruby-identifier">each_pair</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"#{k}#{pair_divider}#{v}"</span> }
|
1124
|
-
<span class="ruby-identifier">s</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">elem_divider</span>)
|
1125
|
-
<span class="ruby-keyword kw">end</span>
|
1126
|
-
</pre>
|
1127
|
-
</div>
|
1128
|
-
</div>
|
1129
|
-
</div>
|
1130
|
-
<div class="method">
|
1131
|
-
<div class="title">
|
1132
|
-
<a name="M000091"></a><b>keys?</b>(*check_keys)
|
1133
|
-
</div>
|
1134
|
-
<div class="description">
|
1135
|
-
<p>
|
1136
|
-
Alias for has_keys?
|
1137
|
-
</p>
|
1138
|
-
</div>
|
1139
|
-
</div>
|
1140
|
-
<div class="method">
|
1141
|
-
<div class="title">
|
1142
|
-
<a name="M000111"></a><b>mash!</b>(&yld)
|
1143
|
-
</div>
|
1144
|
-
<div class="description">
|
1145
|
-
<p>
|
1146
|
-
In place version of mash.
|
1147
|
-
</p>
|
1148
|
-
<pre>
|
1149
|
-
NOTE: Hash#mash! is only useful for Hash. It is not generally
|
1150
|
-
applicable to Enumerable.
|
1151
|
-
</pre>
|
1152
|
-
</div>
|
1153
|
-
<div class="aka">
|
1154
|
-
This method is also aliased as
|
1155
|
-
<a href="Hash.html#M000112">graph!</a>
|
1156
|
-
</div>
|
1157
|
-
<div class="sourcecode">
|
1158
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000111_source')" id="l_M000111_source">+</a> ]</p>
|
1159
|
-
<div id="M000111_source" class="dyn-source">
|
1160
|
-
<pre>
|
1161
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/mash.rb, line 10</span>
|
1162
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">mash!</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">yld</span>)
|
1163
|
-
<span class="ruby-identifier">replace</span>(<span class="ruby-identifier">mash</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">yld</span>))
|
1164
|
-
<span class="ruby-keyword kw">end</span>
|
1165
|
-
</pre>
|
1166
|
-
</div>
|
1167
|
-
</div>
|
1168
|
-
</div>
|
1169
|
-
<div class="method">
|
1170
|
-
<div class="title">
|
1171
|
-
<a name="M000093"></a><b>only_keys?</b>(*check_keys)
|
1172
|
-
</div>
|
1173
|
-
<div class="description">
|
1174
|
-
<p>
|
1175
|
-
Alias for has_only_keys?
|
1176
|
-
</p>
|
1177
|
-
</div>
|
1178
|
-
</div>
|
1179
|
-
<div class="method">
|
1180
|
-
<div class="title">
|
1181
|
-
<a name="M000104"></a><b>recursive_merge</b>(other)
|
1182
|
-
</div>
|
1183
|
-
<div class="description">
|
1184
|
-
<p>
|
1185
|
-
Same as Hash#merge but <a href="Hash.html#M000084">recursively</a> merges
|
1186
|
-
sub-hashes.
|
1187
|
-
</p>
|
1188
|
-
</div>
|
1189
|
-
<div class="sourcecode">
|
1190
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000104_source')" id="l_M000104_source">+</a> ]</p>
|
1191
|
-
<div id="M000104_source" class="dyn-source">
|
1192
|
-
<pre>
|
1193
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/recursive_merge.rb, line 5</span>
|
1194
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">recursive_merge</span>(<span class="ruby-identifier">other</span>)
|
1195
|
-
<span class="ruby-identifier">hash</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">dup</span>
|
1196
|
-
<span class="ruby-identifier">other</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
|
1197
|
-
<span class="ruby-identifier">myval</span> = <span class="ruby-keyword kw">self</span>[<span class="ruby-identifier">key</span>]
|
1198
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>) <span class="ruby-operator">&&</span> <span class="ruby-identifier">myval</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
|
1199
|
-
<span class="ruby-identifier">hash</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">myval</span>.<span class="ruby-identifier">recursive_merge</span>(<span class="ruby-identifier">value</span>)
|
1200
|
-
<span class="ruby-keyword kw">else</span>
|
1201
|
-
<span class="ruby-identifier">hash</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">value</span>
|
1202
|
-
<span class="ruby-keyword kw">end</span>
|
1203
|
-
<span class="ruby-keyword kw">end</span>
|
1204
|
-
<span class="ruby-identifier">hash</span>
|
1205
|
-
<span class="ruby-keyword kw">end</span>
|
1206
|
-
</pre>
|
1207
|
-
</div>
|
1208
|
-
</div>
|
1209
|
-
</div>
|
1210
|
-
<div class="method">
|
1211
|
-
<div class="title">
|
1212
|
-
<a name="M000105"></a><b>recursive_merge!</b>(other)
|
1213
|
-
</div>
|
1214
|
-
<div class="description">
|
1215
|
-
<p>
|
1216
|
-
Same as Hash#merge! but <a href="Hash.html#M000084">recursively</a> merges
|
1217
|
-
sub-hashes.
|
1218
|
-
</p>
|
1219
|
-
</div>
|
1220
|
-
<div class="sourcecode">
|
1221
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000105_source')" id="l_M000105_source">+</a> ]</p>
|
1222
|
-
<div id="M000105_source" class="dyn-source">
|
1223
|
-
<pre>
|
1224
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/recursive_merge.rb, line 20</span>
|
1225
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">recursive_merge!</span>(<span class="ruby-identifier">other</span>)
|
1226
|
-
<span class="ruby-identifier">other</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
|
1227
|
-
<span class="ruby-identifier">myval</span> = <span class="ruby-keyword kw">self</span>[<span class="ruby-identifier">key</span>]
|
1228
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>) <span class="ruby-operator">&&</span> <span class="ruby-identifier">myval</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
|
1229
|
-
<span class="ruby-identifier">myval</span>.<span class="ruby-identifier">recursive_merge!</span>(<span class="ruby-identifier">value</span>)
|
1230
|
-
<span class="ruby-keyword kw">else</span>
|
1231
|
-
<span class="ruby-keyword kw">self</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">value</span>
|
1232
|
-
<span class="ruby-keyword kw">end</span>
|
1233
|
-
<span class="ruby-keyword kw">end</span>
|
1234
|
-
<span class="ruby-keyword kw">self</span>
|
1235
|
-
<span class="ruby-keyword kw">end</span>
|
1236
|
-
</pre>
|
1237
|
-
</div>
|
1238
|
-
</div>
|
1239
|
-
</div>
|
1240
|
-
<div class="method">
|
1241
|
-
<div class="title">
|
1242
|
-
<a name="M000084"></a><b>recursively</b>() {|h| ...}
|
1243
|
-
</div>
|
1244
|
-
<div class="description">
|
1245
|
-
<p>
|
1246
|
-
Apply a block to hash, and <a href="Hash.html#M000084">recursively</a>
|
1247
|
-
apply that block to each subhash.
|
1248
|
-
</p>
|
1249
|
-
<pre>
|
1250
|
-
h = {:a=>1, :b=>{:b1=>1, :b2=>2}}
|
1251
|
-
h.recursively{|h| h.rekey(&:to_s) }
|
1252
|
-
=> {"a"=>1, "b"=>{"b1"=>1, "b2"=>2}}
|
1253
|
-
</pre>
|
1254
|
-
</div>
|
1255
|
-
<div class="sourcecode">
|
1256
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000084_source')" id="l_M000084_source">+</a> ]</p>
|
1257
|
-
<div id="M000084_source" class="dyn-source">
|
1258
|
-
<pre>
|
1259
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/recursively.rb, line 10</span>
|
1260
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">recursively</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
1261
|
-
<span class="ruby-identifier">h</span> = <span class="ruby-identifier">inject</span>({}) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">hash</span>, (<span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span>)<span class="ruby-operator">|</span>
|
1262
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
|
1263
|
-
<span class="ruby-identifier">hash</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">value</span>.<span class="ruby-identifier">recursively</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
1264
|
-
<span class="ruby-keyword kw">else</span>
|
1265
|
-
<span class="ruby-identifier">hash</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">value</span>
|
1266
|
-
<span class="ruby-keyword kw">end</span>
|
1267
|
-
<span class="ruby-identifier">hash</span>
|
1268
|
-
<span class="ruby-keyword kw">end</span>
|
1269
|
-
<span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">h</span>
|
1270
|
-
<span class="ruby-keyword kw">end</span>
|
1271
|
-
</pre>
|
1272
|
-
</div>
|
1273
|
-
</div>
|
1274
|
-
</div>
|
1275
|
-
<div class="method">
|
1276
|
-
<div class="title">
|
1277
|
-
<a name="M000085"></a><b>recursively!</b>(&block)
|
1278
|
-
</div>
|
1279
|
-
<div class="sourcecode">
|
1280
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000085_source')" id="l_M000085_source">+</a> ]</p>
|
1281
|
-
<div id="M000085_source" class="dyn-source">
|
1282
|
-
<pre>
|
1283
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/recursively.rb, line 24</span>
|
1284
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">recursively!</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
1285
|
-
<span class="ruby-identifier">replace</span>(<span class="ruby-identifier">recursively</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">block</span>))
|
1286
|
-
<span class="ruby-keyword kw">end</span>
|
1287
|
-
</pre>
|
1288
|
-
</div>
|
1289
|
-
</div>
|
1290
|
-
</div>
|
1291
|
-
<div class="method">
|
1292
|
-
<div class="title">
|
1293
|
-
<a name="M000131"></a><b>rekey</b>(*args, &block)
|
1294
|
-
</div>
|
1295
|
-
<div class="description">
|
1296
|
-
<p>
|
1297
|
-
Rekey a hash.
|
1298
|
-
</p>
|
1299
|
-
<pre>
|
1300
|
-
rekey()
|
1301
|
-
rekey(to_key, from_key)
|
1302
|
-
rekey{ |key| ... }
|
1303
|
-
</pre>
|
1304
|
-
<p>
|
1305
|
-
If no arguments or block are given, then all keys are converted to Symbols.
|
1306
|
-
</p>
|
1307
|
-
<p>
|
1308
|
-
If two keys are given, then the second key is changed to the first. You can
|
1309
|
-
think of it as <tt>alias</tt> for hash keys.
|
1310
|
-
</p>
|
1311
|
-
<pre>
|
1312
|
-
foo = { :a=>1, :b=>2 }
|
1313
|
-
foo.rekey('a',:a) #=> { 'a'=>1, :b=>2 }
|
1314
|
-
foo.rekey('b',:b) #=> { 'a'=>1, 'b'=>2 }
|
1315
|
-
foo.rekey('foo','bar') #=> { 'a'=>1, 'b'=>2 }
|
1316
|
-
</pre>
|
1317
|
-
<p>
|
1318
|
-
If a block is given, converts all keys in the <a href="Hash.html">Hash</a>
|
1319
|
-
accroding to the given block. If the block returns <tt>nil</tt> for given
|
1320
|
-
key, then that key will be left intact.
|
1321
|
-
</p>
|
1322
|
-
<pre>
|
1323
|
-
foo = { :name=>'Gavin', :wife=>:Lisa }
|
1324
|
-
foo.rekey{ |k| k.to_s } #=> { "name"=>"Gavin", "wife"=>:Lisa }
|
1325
|
-
foo.inspect #=> { :name =>"Gavin", :wife=>:Lisa }
|
1326
|
-
</pre>
|
1327
|
-
<p>
|
1328
|
-
CREDIT: Trans, Gavin Kistner
|
1329
|
-
</p>
|
1330
|
-
</div>
|
1331
|
-
<div class="sourcecode">
|
1332
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000131_source')" id="l_M000131_source">+</a> ]</p>
|
1333
|
-
<div id="M000131_source" class="dyn-source">
|
1334
|
-
<pre>
|
1335
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/rekey.rb, line 32</span>
|
1336
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">rekey</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
1337
|
-
<span class="ruby-identifier">dup</span>.<span class="ruby-identifier">rekey!</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
1338
|
-
<span class="ruby-keyword kw">end</span>
|
1339
|
-
</pre>
|
1340
|
-
</div>
|
1341
|
-
</div>
|
1342
|
-
</div>
|
1343
|
-
<div class="method">
|
1344
|
-
<div class="title">
|
1345
|
-
<a name="M000132"></a><b>rekey!</b>(*args, &block)
|
1346
|
-
</div>
|
1347
|
-
<div class="description">
|
1348
|
-
<p>
|
1349
|
-
Synonym for <a href="Hash.html#M000131">Hash#rekey</a>, but modifies the
|
1350
|
-
receiver in place (and returns it).
|
1351
|
-
</p>
|
1352
|
-
<pre>
|
1353
|
-
foo = { :name=>'Gavin', :wife=>:Lisa }
|
1354
|
-
foo.rekey!{ |k| k.to_s } #=> { "name"=>"Gavin", "wife"=>:Lisa }
|
1355
|
-
foo.inspect #=> { "name"=>"Gavin", "wife"=>:Lisa }
|
1356
|
-
</pre>
|
1357
|
-
<p>
|
1358
|
-
CREDIT: Trans, Gavin Kistner
|
1359
|
-
</p>
|
1360
|
-
</div>
|
1361
|
-
<div class="sourcecode">
|
1362
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000132_source')" id="l_M000132_source">+</a> ]</p>
|
1363
|
-
<div id="M000132_source" class="dyn-source">
|
1364
|
-
<pre>
|
1365
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/rekey.rb, line 44</span>
|
1366
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">rekey!</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
1367
|
-
<span class="ruby-comment cmt"># for backward comptability (TODO: DEPRECATE).</span>
|
1368
|
-
<span class="ruby-identifier">block</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">pop</span>.<span class="ruby-identifier">to_sym</span>.<span class="ruby-identifier">to_proc</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>
|
1369
|
-
<span class="ruby-comment cmt"># if no args use block.</span>
|
1370
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">empty?</span>
|
1371
|
-
<span class="ruby-identifier">block</span> = <span class="ruby-identifier">lambda</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-identifier">k</span>.<span class="ruby-identifier">to_sym</span>} <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">block</span>
|
1372
|
-
<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span>
|
1373
|
-
<span class="ruby-identifier">nk</span> = <span class="ruby-identifier">block</span>[<span class="ruby-identifier">k</span>]
|
1374
|
-
<span class="ruby-keyword kw">self</span>[<span class="ruby-identifier">nk</span>]=<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">k</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">nk</span>
|
1375
|
-
<span class="ruby-keyword kw">end</span>
|
1376
|
-
<span class="ruby-keyword kw">else</span>
|
1377
|
-
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">"3 for 2"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block</span>
|
1378
|
-
<span class="ruby-identifier">to</span>, <span class="ruby-identifier">from</span> = <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>
|
1379
|
-
<span class="ruby-keyword kw">self</span>[<span class="ruby-identifier">to</span>] = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">from</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">from</span>)
|
1380
|
-
<span class="ruby-keyword kw">end</span>
|
1381
|
-
<span class="ruby-keyword kw">self</span>
|
1382
|
-
<span class="ruby-keyword kw">end</span>
|
1383
|
-
</pre>
|
1384
|
-
</div>
|
1385
|
-
</div>
|
1386
|
-
</div>
|
1387
|
-
<div class="method">
|
1388
|
-
<div class="title">
|
1389
|
-
<a name="M000127"></a><b>replace_each</b>( {|| ...}
|
1390
|
-
</div>
|
1391
|
-
<div class="description">
|
1392
|
-
<p>
|
1393
|
-
Same as <a href="Hash.html#M000133">update_each</a>, but deletes the key
|
1394
|
-
element first.
|
1395
|
-
</p>
|
1396
|
-
<p>
|
1397
|
-
CREDIT: Trans
|
1398
|
-
</p>
|
1399
|
-
</div>
|
1400
|
-
<div class="sourcecode">
|
1401
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000127_source')" id="l_M000127_source">+</a> ]</p>
|
1402
|
-
<div id="M000127_source" class="dyn-source">
|
1403
|
-
<pre>
|
1404
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/replace_each.rb, line 7</span>
|
1405
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">replace_each</span> <span class="ruby-comment cmt"># :yield:</span>
|
1406
|
-
<span class="ruby-identifier">dup</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
|
1407
|
-
<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">k</span>)
|
1408
|
-
<span class="ruby-identifier">update</span>(<span class="ruby-keyword kw">yield</span>(<span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span>))
|
1409
|
-
<span class="ruby-keyword kw">end</span>
|
1410
|
-
<span class="ruby-keyword kw">self</span>
|
1411
|
-
<span class="ruby-keyword kw">end</span>
|
1412
|
-
</pre>
|
1413
|
-
</div>
|
1414
|
-
</div>
|
1415
|
-
</div>
|
1416
|
-
<div class="method">
|
1417
|
-
<div class="title">
|
1418
|
-
<a name="M000095"></a><b>reverse_merge</b>(other)
|
1419
|
-
</div>
|
1420
|
-
<div class="description">
|
1421
|
-
<p>
|
1422
|
-
Allows for reverse merging where its the keys in the calling hash that wins
|
1423
|
-
over those in the <tt>other_hash</tt>. This is particularly useful for
|
1424
|
-
initializing an incoming option hash with default values:
|
1425
|
-
</p>
|
1426
|
-
<pre>
|
1427
|
-
def setup(options = {})
|
1428
|
-
options.reverse_merge! :size => 25, :velocity => 10
|
1429
|
-
end
|
1430
|
-
</pre>
|
1431
|
-
<p>
|
1432
|
-
The default :size and :velocity is only set if the <tt>options</tt> passed
|
1433
|
-
in doesn‘t already have those keys set.
|
1434
|
-
</p>
|
1435
|
-
</div>
|
1436
|
-
<div class="sourcecode">
|
1437
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000095_source')" id="l_M000095_source">+</a> ]</p>
|
1438
|
-
<div id="M000095_source" class="dyn-source">
|
1439
|
-
<pre>
|
1440
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/merge.rb, line 15</span>
|
1441
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reverse_merge</span>(<span class="ruby-identifier">other</span>)
|
1442
|
-
<span class="ruby-identifier">other</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-keyword kw">self</span>)
|
1443
|
-
<span class="ruby-keyword kw">end</span>
|
1444
|
-
</pre>
|
1445
|
-
</div>
|
1446
|
-
</div>
|
1447
|
-
</div>
|
1448
|
-
<div class="method">
|
1449
|
-
<div class="title">
|
1450
|
-
<a name="M000096"></a><b>reverse_merge!</b>(other)
|
1451
|
-
</div>
|
1452
|
-
<div class="description">
|
1453
|
-
<p>
|
1454
|
-
Inplace form of <a href="Hash.html#M000095">reverse_merge</a>.
|
1455
|
-
</p>
|
1456
|
-
</div>
|
1457
|
-
<div class="aka">
|
1458
|
-
This method is also aliased as
|
1459
|
-
<a href="Hash.html#M000097">reverse_update</a>
|
1460
|
-
</div>
|
1461
|
-
<div class="sourcecode">
|
1462
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000096_source')" id="l_M000096_source">+</a> ]</p>
|
1463
|
-
<div id="M000096_source" class="dyn-source">
|
1464
|
-
<pre>
|
1465
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/merge.rb, line 21</span>
|
1466
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reverse_merge!</span>(<span class="ruby-identifier">other</span>)
|
1467
|
-
<span class="ruby-identifier">replace</span>(<span class="ruby-identifier">reverse_merge</span>(<span class="ruby-identifier">other</span>))
|
1468
|
-
<span class="ruby-keyword kw">end</span>
|
1469
|
-
</pre>
|
1470
|
-
</div>
|
1471
|
-
</div>
|
1472
|
-
</div>
|
1473
|
-
<div class="method">
|
1474
|
-
<div class="title">
|
1475
|
-
<a name="M000097"></a><b>reverse_update</b>(other)
|
1476
|
-
</div>
|
1477
|
-
<div class="description">
|
1478
|
-
<p>
|
1479
|
-
Alias for <a href="Hash.html#M000095">reverse_merge</a>!
|
1480
|
-
</p>
|
1481
|
-
</div>
|
1482
|
-
</div>
|
1483
|
-
<div class="method">
|
1484
|
-
<div class="title">
|
1485
|
-
<a name="M000109"></a><b>select!</b>() {|k,v| ...}
|
1486
|
-
</div>
|
1487
|
-
<div class="description">
|
1488
|
-
<p>
|
1489
|
-
In-place version of Hash#select. The opposite of the built-in Hash#reject!.
|
1490
|
-
</p>
|
1491
|
-
<p>
|
1492
|
-
CREDIT: Gavin Sinclair, Noah Gibbs
|
1493
|
-
</p>
|
1494
|
-
</div>
|
1495
|
-
<div class="sourcecode">
|
1496
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000109_source')" id="l_M000109_source">+</a> ]</p>
|
1497
|
-
<div id="M000109_source" class="dyn-source">
|
1498
|
-
<pre>
|
1499
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/select.rb, line 8</span>
|
1500
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">select!</span>
|
1501
|
-
<span class="ruby-identifier">reject!</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-keyword kw">not</span> <span class="ruby-keyword kw">yield</span>(<span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span>) }
|
1502
|
-
<span class="ruby-keyword kw">end</span>
|
1503
|
-
</pre>
|
1504
|
-
</div>
|
1505
|
-
</div>
|
1506
|
-
</div>
|
1507
|
-
<div class="method">
|
1508
|
-
<div class="title">
|
1509
|
-
<a name="M000128"></a><b>slice</b>(*keep_keys)
|
1510
|
-
</div>
|
1511
|
-
<div class="description">
|
1512
|
-
<p>
|
1513
|
-
Returns a new hash with only the given keys.
|
1514
|
-
</p>
|
1515
|
-
</div>
|
1516
|
-
<div class="sourcecode">
|
1517
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000128_source')" id="l_M000128_source">+</a> ]</p>
|
1518
|
-
<div id="M000128_source" class="dyn-source">
|
1519
|
-
<pre>
|
1520
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/slice.rb, line 9</span>
|
1521
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">slice</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">keep_keys</span>)
|
1522
|
-
<span class="ruby-identifier">h</span> = {}
|
1523
|
-
<span class="ruby-identifier">keep_keys</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span>
|
1524
|
-
<span class="ruby-identifier">h</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">fetch</span>(<span class="ruby-identifier">key</span>)
|
1525
|
-
<span class="ruby-keyword kw">end</span>
|
1526
|
-
<span class="ruby-identifier">h</span>
|
1527
|
-
<span class="ruby-keyword kw">end</span>
|
1528
|
-
</pre>
|
1529
|
-
</div>
|
1530
|
-
</div>
|
1531
|
-
</div>
|
1532
|
-
<div class="method">
|
1533
|
-
<div class="title">
|
1534
|
-
<a name="M000129"></a><b>slice!</b>(*keep_keys)
|
1535
|
-
</div>
|
1536
|
-
<div class="description">
|
1537
|
-
<p>
|
1538
|
-
Replaces hash with a new hash having only the given keys. This return the
|
1539
|
-
hash of keys removed.
|
1540
|
-
</p>
|
1541
|
-
<pre>
|
1542
|
-
h = {:a=>1, :b=>2}
|
1543
|
-
h.slice!(:a) #=> {:a=>1}
|
1544
|
-
h #=> {:b=>2}
|
1545
|
-
</pre>
|
1546
|
-
</div>
|
1547
|
-
<div class="sourcecode">
|
1548
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000129_source')" id="l_M000129_source">+</a> ]</p>
|
1549
|
-
<div id="M000129_source" class="dyn-source">
|
1550
|
-
<pre>
|
1551
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/slice.rb, line 24</span>
|
1552
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">slice!</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">keep_keys</span>)
|
1553
|
-
<span class="ruby-identifier">removed</span> = <span class="ruby-identifier">except</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">keep_keys</span>)
|
1554
|
-
<span class="ruby-identifier">replace</span>(<span class="ruby-identifier">slice</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">keep_keys</span>))
|
1555
|
-
<span class="ruby-identifier">removed</span>
|
1556
|
-
<span class="ruby-keyword kw">end</span>
|
1557
|
-
</pre>
|
1558
|
-
</div>
|
1559
|
-
</div>
|
1560
|
-
</div>
|
1561
|
-
<div class="method">
|
1562
|
-
<div class="title">
|
1563
|
-
<a name="M000123"></a><b>stringify_keys</b>(&filter)
|
1564
|
-
</div>
|
1565
|
-
<div class="description">
|
1566
|
-
<p>
|
1567
|
-
Converts all keys in the <a href="Hash.html">Hash</a> to Strings, returning
|
1568
|
-
a new <a href="Hash.html">Hash</a>. With a <tt>filter</tt> parameter,
|
1569
|
-
limits conversion to only a certain selection of keys.
|
1570
|
-
</p>
|
1571
|
-
<pre>
|
1572
|
-
foo = { :name=>'Gavin', :wife=>:Lisa }
|
1573
|
-
foo.stringify_keys #=> { "name"=>"Gavin", "wife"=>:Lisa }
|
1574
|
-
foo.inspect #=> { :name =>"Gavin", :wife=>:Lisa }
|
1575
|
-
</pre>
|
1576
|
-
<p>
|
1577
|
-
This method is considered archaic. Use <a
|
1578
|
-
href="Hash.html#M000131">rekey</a> instead.
|
1579
|
-
</p>
|
1580
|
-
</div>
|
1581
|
-
<div class="sourcecode">
|
1582
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000123_source')" id="l_M000123_source">+</a> ]</p>
|
1583
|
-
<div id="M000123_source" class="dyn-source">
|
1584
|
-
<pre>
|
1585
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/symbolize_keys.rb, line 54</span>
|
1586
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stringify_keys</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">filter</span>)
|
1587
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">filter</span>
|
1588
|
-
<span class="ruby-identifier">rekey</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-identifier">filter</span>[<span class="ruby-identifier">k</span>] <span class="ruby-operator">?</span> <span class="ruby-identifier">k</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">nil</span> }
|
1589
|
-
<span class="ruby-keyword kw">else</span>
|
1590
|
-
<span class="ruby-identifier">rekey</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-identifier">k</span>.<span class="ruby-identifier">to_s</span> }
|
1591
|
-
<span class="ruby-keyword kw">end</span>
|
1592
|
-
<span class="ruby-keyword kw">end</span>
|
1593
|
-
</pre>
|
1594
|
-
</div>
|
1595
|
-
</div>
|
1596
|
-
</div>
|
1597
|
-
<div class="method">
|
1598
|
-
<div class="title">
|
1599
|
-
<a name="M000124"></a><b>stringify_keys!</b>(&filter)
|
1600
|
-
</div>
|
1601
|
-
<div class="description">
|
1602
|
-
<p>
|
1603
|
-
Synonym for <a href="Hash.html#M000123">Hash#stringify_keys</a>, but
|
1604
|
-
modifies the receiver in place and returns it. With a <tt>filter</tt>
|
1605
|
-
parameter, limits conversion to only a certain selection of keys.
|
1606
|
-
</p>
|
1607
|
-
<pre>
|
1608
|
-
foo = { :name=>'Gavin', :wife=>:Lisa }
|
1609
|
-
foo.stringify_keys! #=> { "name"=>"Gavin", "wife"=>:Lisa }
|
1610
|
-
foo.inspect #=> { "name"=>"Gavin", "wife"=>:Lisa }
|
1611
|
-
</pre>
|
1612
|
-
<p>
|
1613
|
-
This method is considered archaic. Use <a
|
1614
|
-
href="Hash.html#M000131">rekey</a> instead.
|
1615
|
-
</p>
|
1616
|
-
</div>
|
1617
|
-
<div class="sourcecode">
|
1618
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000124_source')" id="l_M000124_source">+</a> ]</p>
|
1619
|
-
<div id="M000124_source" class="dyn-source">
|
1620
|
-
<pre>
|
1621
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/symbolize_keys.rb, line 73</span>
|
1622
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stringify_keys!</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">filter</span>)
|
1623
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">filter</span>
|
1624
|
-
<span class="ruby-identifier">rekey!</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-identifier">filter</span>[<span class="ruby-identifier">k</span>] <span class="ruby-operator">?</span> <span class="ruby-identifier">k</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">nil</span> }
|
1625
|
-
<span class="ruby-keyword kw">else</span>
|
1626
|
-
<span class="ruby-identifier">rekey!</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-identifier">k</span>.<span class="ruby-identifier">to_s</span> }
|
1627
|
-
<span class="ruby-keyword kw">end</span>
|
1628
|
-
<span class="ruby-keyword kw">end</span>
|
1629
|
-
</pre>
|
1630
|
-
</div>
|
1631
|
-
</div>
|
1632
|
-
</div>
|
1633
|
-
<div class="method">
|
1634
|
-
<div class="title">
|
1635
|
-
<a name="M000119"></a><b>swap!</b>(key1, key2)
|
1636
|
-
</div>
|
1637
|
-
<div class="description">
|
1638
|
-
<p>
|
1639
|
-
Swap the values of a pair of keys in place.
|
1640
|
-
</p>
|
1641
|
-
<pre>
|
1642
|
-
{:a=>1,:b=>2}.swap!(:a,:b) #=> {:a=>2,:b=>1}
|
1643
|
-
</pre>
|
1644
|
-
<p>
|
1645
|
-
CREDIT: Gavin Sinclair
|
1646
|
-
</p>
|
1647
|
-
</div>
|
1648
|
-
<div class="sourcecode">
|
1649
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000119_source')" id="l_M000119_source">+</a> ]</p>
|
1650
|
-
<div id="M000119_source" class="dyn-source">
|
1651
|
-
<pre>
|
1652
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/swap.rb, line 9</span>
|
1653
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">swap!</span>(<span class="ruby-identifier">key1</span>, <span class="ruby-identifier">key2</span>)
|
1654
|
-
<span class="ruby-identifier">tmp</span> = <span class="ruby-keyword kw">self</span>[<span class="ruby-identifier">key1</span>]
|
1655
|
-
<span class="ruby-keyword kw">self</span>[<span class="ruby-identifier">key1</span>] = <span class="ruby-keyword kw">self</span>[<span class="ruby-identifier">key2</span>]
|
1656
|
-
<span class="ruby-keyword kw">self</span>[<span class="ruby-identifier">key2</span>] = <span class="ruby-identifier">tmp</span>
|
1657
|
-
<span class="ruby-keyword kw">self</span>
|
1658
|
-
<span class="ruby-keyword kw">end</span>
|
1659
|
-
</pre>
|
1660
|
-
</div>
|
1661
|
-
</div>
|
1662
|
-
</div>
|
1663
|
-
<div class="method">
|
1664
|
-
<div class="title">
|
1665
|
-
<a name="M000121"></a><b>symbolize_keys</b>(&filter)
|
1666
|
-
</div>
|
1667
|
-
<div class="description">
|
1668
|
-
<p>
|
1669
|
-
Converts all keys in the <a href="Hash.html">Hash</a> to Symbols, returning
|
1670
|
-
a new <a href="Hash.html">Hash</a>. With a <tt>filter</tt>, limits
|
1671
|
-
conversion to only a certain selection of keys.
|
1672
|
-
</p>
|
1673
|
-
<pre>
|
1674
|
-
foo = { :name=>'Gavin', 'wife'=>:Lisa }
|
1675
|
-
foo.symbolize_keys #=> { :name=>"Gavin", :wife=>:Lisa }
|
1676
|
-
foo.inspect #=> { "name" =>"Gavin", "wife"=>:Lisa }
|
1677
|
-
</pre>
|
1678
|
-
<p>
|
1679
|
-
This method is considered archaic. Use <a
|
1680
|
-
href="Hash.html#M000131">rekey</a> instead.
|
1681
|
-
</p>
|
1682
|
-
</div>
|
1683
|
-
<div class="sourcecode">
|
1684
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000121_source')" id="l_M000121_source">+</a> ]</p>
|
1685
|
-
<div id="M000121_source" class="dyn-source">
|
1686
|
-
<pre>
|
1687
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/symbolize_keys.rb, line 20</span>
|
1688
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">symbolize_keys</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">filter</span>)
|
1689
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">filter</span>
|
1690
|
-
<span class="ruby-identifier">rekey</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-identifier">filter</span>[<span class="ruby-identifier">k</span>] <span class="ruby-operator">?</span> <span class="ruby-identifier">k</span>.<span class="ruby-identifier">to_sym</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">nil</span> }
|
1691
|
-
<span class="ruby-keyword kw">else</span>
|
1692
|
-
<span class="ruby-identifier">rekey</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-identifier">k</span>.<span class="ruby-identifier">to_sym</span> }
|
1693
|
-
<span class="ruby-keyword kw">end</span>
|
1694
|
-
<span class="ruby-keyword kw">end</span>
|
1695
|
-
</pre>
|
1696
|
-
</div>
|
1697
|
-
</div>
|
1698
|
-
</div>
|
1699
|
-
<div class="method">
|
1700
|
-
<div class="title">
|
1701
|
-
<a name="M000122"></a><b>symbolize_keys!</b>(&filter)
|
1702
|
-
</div>
|
1703
|
-
<div class="description">
|
1704
|
-
<p>
|
1705
|
-
Synonym for <a href="Hash.html#M000121">Hash#symbolize_keys</a>, but
|
1706
|
-
modifies the receiver in place and returns it. With a <tt>filter</tt>
|
1707
|
-
parameter, limits conversion to only a certain selection of keys.
|
1708
|
-
</p>
|
1709
|
-
<pre>
|
1710
|
-
foo = { 'name'=>'Gavin', 'wife'=>:Lisa }
|
1711
|
-
foo.symbolize_keys! #=> { :name=>"Gavin", :wife=>:Lisa }
|
1712
|
-
foo.inspect #=> { :name=>"Gavin", :wife=>:Lisa }
|
1713
|
-
</pre>
|
1714
|
-
<p>
|
1715
|
-
This method is considered archaic. Use <a
|
1716
|
-
href="Hash.html#M000131">rekey</a> instead.
|
1717
|
-
</p>
|
1718
|
-
</div>
|
1719
|
-
<div class="sourcecode">
|
1720
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000122_source')" id="l_M000122_source">+</a> ]</p>
|
1721
|
-
<div id="M000122_source" class="dyn-source">
|
1722
|
-
<pre>
|
1723
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/symbolize_keys.rb, line 37</span>
|
1724
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">symbolize_keys!</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">filter</span>)
|
1725
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">filter</span>
|
1726
|
-
<span class="ruby-identifier">rekey!</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-identifier">filter</span>[<span class="ruby-identifier">k</span>] <span class="ruby-operator">?</span> <span class="ruby-identifier">k</span>.<span class="ruby-identifier">to_sym</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">nil</span> }
|
1727
|
-
<span class="ruby-keyword kw">else</span>
|
1728
|
-
<span class="ruby-identifier">rekey!</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-identifier">k</span>.<span class="ruby-identifier">to_sym</span> }
|
1729
|
-
<span class="ruby-keyword kw">end</span>
|
1730
|
-
<span class="ruby-keyword kw">end</span>
|
1731
|
-
</pre>
|
1732
|
-
</div>
|
1733
|
-
</div>
|
1734
|
-
</div>
|
1735
|
-
<div class="method">
|
1736
|
-
<div class="title">
|
1737
|
-
<a name="M000075"></a><b>to_h</b>()
|
1738
|
-
</div>
|
1739
|
-
<div class="description">
|
1740
|
-
<p>
|
1741
|
-
Return a rehashing of <em>self</em>.
|
1742
|
-
</p>
|
1743
|
-
<pre>
|
1744
|
-
{"a"=>1,"b"=>2}.to_h #=> {"b"=>2,"a"=>1}
|
1745
|
-
</pre>
|
1746
|
-
<p>
|
1747
|
-
CREDIT: Forian Gross
|
1748
|
-
</p>
|
1749
|
-
</div>
|
1750
|
-
<div class="sourcecode">
|
1751
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000075_source')" id="l_M000075_source">+</a> ]</p>
|
1752
|
-
<div id="M000075_source" class="dyn-source">
|
1753
|
-
<pre>
|
1754
|
-
<span class="ruby-comment cmt"># File lib/core/facets/to_hash.rb, line 209</span>
|
1755
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_h</span>; <span class="ruby-identifier">rehash</span>; <span class="ruby-keyword kw">end</span>
|
1756
|
-
</pre>
|
1757
|
-
</div>
|
1758
|
-
</div>
|
1759
|
-
</div>
|
1760
|
-
<div class="method">
|
1761
|
-
<div class="title">
|
1762
|
-
<a name="M000076"></a><b>to_hash</b>()
|
1763
|
-
</div>
|
1764
|
-
<div class="description">
|
1765
|
-
<p>
|
1766
|
-
Returns <em>self</em>.
|
1767
|
-
</p>
|
1768
|
-
<p>
|
1769
|
-
CREDIT: Trans
|
1770
|
-
</p>
|
1771
|
-
</div>
|
1772
|
-
<div class="sourcecode">
|
1773
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000076_source')" id="l_M000076_source">+</a> ]</p>
|
1774
|
-
<div id="M000076_source" class="dyn-source">
|
1775
|
-
<pre>
|
1776
|
-
<span class="ruby-comment cmt"># File lib/core/facets/to_hash.rb, line 215</span>
|
1777
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_hash</span>; <span class="ruby-keyword kw">self</span>; <span class="ruby-keyword kw">end</span>
|
1778
|
-
</pre>
|
1779
|
-
</div>
|
1780
|
-
</div>
|
1781
|
-
</div>
|
1782
|
-
<div class="method">
|
1783
|
-
<div class="title">
|
1784
|
-
<a name="M000106"></a><b>to_proc</b>()
|
1785
|
-
</div>
|
1786
|
-
<div class="description">
|
1787
|
-
<p>
|
1788
|
-
Constructs a <a href="Proc.html">Proc</a> object from a hash such that the
|
1789
|
-
parameter of the <a href="Proc.html">Proc</a> is assigned the hash keys as
|
1790
|
-
attributes.
|
1791
|
-
</p>
|
1792
|
-
<pre>
|
1793
|
-
h = { :a => 1 }
|
1794
|
-
p = h.to_proc
|
1795
|
-
o = OpenStruct.new
|
1796
|
-
p.call(o)
|
1797
|
-
o.a #=> 1
|
1798
|
-
</pre>
|
1799
|
-
<p>
|
1800
|
-
CREDIT: Trans
|
1801
|
-
</p>
|
1802
|
-
</div>
|
1803
|
-
<div class="sourcecode">
|
1804
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000106_source')" id="l_M000106_source">+</a> ]</p>
|
1805
|
-
<div id="M000106_source" class="dyn-source">
|
1806
|
-
<pre>
|
1807
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/to_proc.rb, line 15</span>
|
1808
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_proc</span>
|
1809
|
-
<span class="ruby-identifier">lambda</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">o</span><span class="ruby-operator">|</span>
|
1810
|
-
<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
|
1811
|
-
<span class="ruby-identifier">ke</span> = <span class="ruby-node">"#{k}="</span>
|
1812
|
-
<span class="ruby-identifier">o</span>.<span class="ruby-identifier">__send__</span>(<span class="ruby-identifier">ke</span>, <span class="ruby-identifier">v</span>)
|
1813
|
-
<span class="ruby-keyword kw">end</span>
|
1814
|
-
<span class="ruby-keyword kw">end</span>
|
1815
|
-
<span class="ruby-keyword kw">end</span>
|
1816
|
-
</pre>
|
1817
|
-
</div>
|
1818
|
-
</div>
|
1819
|
-
</div>
|
1820
|
-
<div class="method">
|
1821
|
-
<div class="title">
|
1822
|
-
<a name="M000107"></a><b>to_proc_with_reponse</b>()
|
1823
|
-
</div>
|
1824
|
-
<div class="description">
|
1825
|
-
<p>
|
1826
|
-
A fault-tolerent version of <a href="Hash.html#M000106">to_proc</a>.
|
1827
|
-
</p>
|
1828
|
-
<p>
|
1829
|
-
It works just like <a href="Hash.html#M000106">to_proc</a>, but the block
|
1830
|
-
will make sure# the object responds to the assignment.
|
1831
|
-
</p>
|
1832
|
-
<p>
|
1833
|
-
CREDIT: Trans
|
1834
|
-
</p>
|
1835
|
-
</div>
|
1836
|
-
<div class="sourcecode">
|
1837
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000107_source')" id="l_M000107_source">+</a> ]</p>
|
1838
|
-
<div id="M000107_source" class="dyn-source">
|
1839
|
-
<pre>
|
1840
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/to_proc.rb, line 31</span>
|
1841
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_proc_with_reponse</span>
|
1842
|
-
<span class="ruby-identifier">lambda</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">o</span><span class="ruby-operator">|</span>
|
1843
|
-
<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
|
1844
|
-
<span class="ruby-identifier">ke</span> = <span class="ruby-node">"#{k}="</span>
|
1845
|
-
<span class="ruby-identifier">o</span>.<span class="ruby-identifier">__send__</span>(<span class="ruby-identifier">ke</span>, <span class="ruby-identifier">v</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">ke</span>)
|
1846
|
-
<span class="ruby-keyword kw">end</span>
|
1847
|
-
<span class="ruby-keyword kw">end</span>
|
1848
|
-
<span class="ruby-keyword kw">end</span>
|
1849
|
-
</pre>
|
1850
|
-
</div>
|
1851
|
-
</div>
|
1852
|
-
</div>
|
1853
|
-
<div class="method">
|
1854
|
-
<div class="title">
|
1855
|
-
<a name="M000120"></a><b>to_struct</b>(struct_name)
|
1856
|
-
</div>
|
1857
|
-
<div class="description">
|
1858
|
-
<p>
|
1859
|
-
A method to convert a <a href="Hash.html">Hash</a> into a <a
|
1860
|
-
href="Struct.html">Struct</a>.
|
1861
|
-
</p>
|
1862
|
-
<pre>
|
1863
|
-
h = {:name=>"Dan","age"=>33,"rank"=>"SrA","grade"=>"E4"}
|
1864
|
-
s = h.to_struct("Foo")
|
1865
|
-
</pre>
|
1866
|
-
<p>
|
1867
|
-
TODO: Is this robust enough considerd hashes aren‘t ordered?
|
1868
|
-
</p>
|
1869
|
-
<p>
|
1870
|
-
CREDIT: Daniel Berger
|
1871
|
-
</p>
|
1872
|
-
</div>
|
1873
|
-
<div class="sourcecode">
|
1874
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000120_source')" id="l_M000120_source">+</a> ]</p>
|
1875
|
-
<div id="M000120_source" class="dyn-source">
|
1876
|
-
<pre>
|
1877
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/to_struct.rb, line 12</span>
|
1878
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_struct</span>(<span class="ruby-identifier">struct_name</span>)
|
1879
|
-
<span class="ruby-constant">Struct</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">struct_name</span>,<span class="ruby-operator">*</span><span class="ruby-identifier">keys</span>).<span class="ruby-identifier">new</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">values</span>)
|
1880
|
-
<span class="ruby-keyword kw">end</span>
|
1881
|
-
</pre>
|
1882
|
-
</div>
|
1883
|
-
</div>
|
1884
|
-
</div>
|
1885
|
-
<div class="method">
|
1886
|
-
<div class="title">
|
1887
|
-
<a name="M000098"></a><b>traverse</b>(&b)
|
1888
|
-
</div>
|
1889
|
-
<div class="description">
|
1890
|
-
<p>
|
1891
|
-
Returns a new hash created by traversing the hash and its subhashes,
|
1892
|
-
executing the given block on the key and value. The block should return a
|
1893
|
-
2-element array of the form +[key, value]+.
|
1894
|
-
</p>
|
1895
|
-
<pre>
|
1896
|
-
h = { "A"=>"A", "B"=>"B" }
|
1897
|
-
g = h.traverse { |k,v| [k.downcase, v] }
|
1898
|
-
g #=> { "a"=>"A", "b"=>"B" }
|
1899
|
-
</pre>
|
1900
|
-
<p>
|
1901
|
-
TODO: Contrast these to recursibely —we may not need both.
|
1902
|
-
</p>
|
1903
|
-
<p>
|
1904
|
-
TODO: Testing value to see if it is a <a href="Hash.html">Hash</a> also
|
1905
|
-
catches subclasses of <a href="Hash.html">Hash</a>.
|
1906
|
-
</p>
|
1907
|
-
<pre>
|
1908
|
-
This is probably not the right thing to do and should catch Hashes only (?)
|
1909
|
-
</pre>
|
1910
|
-
<p>
|
1911
|
-
CREDIT: Trans
|
1912
|
-
</p>
|
1913
|
-
</div>
|
1914
|
-
<div class="sourcecode">
|
1915
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000098_source')" id="l_M000098_source">+</a> ]</p>
|
1916
|
-
<div id="M000098_source" class="dyn-source">
|
1917
|
-
<pre>
|
1918
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/traverse.rb, line 18</span>
|
1919
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">traverse</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">b</span>)
|
1920
|
-
<span class="ruby-identifier">inject</span>({}) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">h</span>,(<span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span>)<span class="ruby-operator">|</span>
|
1921
|
-
<span class="ruby-identifier">v</span> = ( <span class="ruby-constant">Hash</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">v</span> <span class="ruby-value">? </span><span class="ruby-identifier">v</span>.<span class="ruby-identifier">traverse</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">b</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">v</span> )
|
1922
|
-
<span class="ruby-identifier">nk</span>, <span class="ruby-identifier">nv</span> = <span class="ruby-identifier">b</span>[<span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span>]
|
1923
|
-
<span class="ruby-identifier">h</span>[<span class="ruby-identifier">nk</span>] = <span class="ruby-identifier">nv</span> <span class="ruby-comment cmt">#( Hash === v ? v.traverse(base,&b) : nv )</span>
|
1924
|
-
<span class="ruby-identifier">h</span>
|
1925
|
-
<span class="ruby-keyword kw">end</span>
|
1926
|
-
<span class="ruby-keyword kw">end</span>
|
1927
|
-
</pre>
|
1928
|
-
</div>
|
1929
|
-
</div>
|
1930
|
-
</div>
|
1931
|
-
<div class="method">
|
1932
|
-
<div class="title">
|
1933
|
-
<a name="M000099"></a><b>traverse!</b>(&b)
|
1934
|
-
</div>
|
1935
|
-
<div class="description">
|
1936
|
-
<p>
|
1937
|
-
In place version of <a href="Hash.html#M000098">traverse</a>, which
|
1938
|
-
traverses the hash and its subhashes, executing the given block on the key
|
1939
|
-
and value.
|
1940
|
-
</p>
|
1941
|
-
<pre>
|
1942
|
-
h = { "A"=>"A", "B"=>"B" }
|
1943
|
-
h.traverse! { |k,v| [k.downcase, v] }
|
1944
|
-
h #=> { "a"=>"A", "b"=>"B" }
|
1945
|
-
</pre>
|
1946
|
-
<p>
|
1947
|
-
CREDIT: Trans
|
1948
|
-
</p>
|
1949
|
-
</div>
|
1950
|
-
<div class="sourcecode">
|
1951
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000099_source')" id="l_M000099_source">+</a> ]</p>
|
1952
|
-
<div id="M000099_source" class="dyn-source">
|
1953
|
-
<pre>
|
1954
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/traverse.rb, line 36</span>
|
1955
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">traverse!</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">b</span>)
|
1956
|
-
<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">replace</span>( <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">traverse</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">b</span>) )
|
1957
|
-
<span class="ruby-keyword kw">end</span>
|
1958
|
-
</pre>
|
1959
|
-
</div>
|
1960
|
-
</div>
|
1961
|
-
</div>
|
1962
|
-
<div class="method">
|
1963
|
-
<div class="title">
|
1964
|
-
<a name="M000133"></a><b>update_each</b>( {|| ...}
|
1965
|
-
</div>
|
1966
|
-
<div class="description">
|
1967
|
-
<p>
|
1968
|
-
Iterates through each pair and updates a the hash in place. This is
|
1969
|
-
formally equivalent to mash! But does not use mash to accomplish the task.
|
1970
|
-
Hence <a href="Hash.html#M000133">update_each</a> is probably a touch
|
1971
|
-
faster.
|
1972
|
-
</p>
|
1973
|
-
<p>
|
1974
|
-
CREDIT: Trans
|
1975
|
-
</p>
|
1976
|
-
</div>
|
1977
|
-
<div class="sourcecode">
|
1978
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000133_source')" id="l_M000133_source">+</a> ]</p>
|
1979
|
-
<div id="M000133_source" class="dyn-source">
|
1980
|
-
<pre>
|
1981
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/update_each.rb, line 10</span>
|
1982
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">update_each</span> <span class="ruby-comment cmt"># :yield:</span>
|
1983
|
-
<span class="ruby-identifier">dup</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
|
1984
|
-
<span class="ruby-identifier">update</span>(<span class="ruby-keyword kw">yield</span>(<span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span>))
|
1985
|
-
<span class="ruby-keyword kw">end</span>
|
1986
|
-
<span class="ruby-keyword kw">self</span>
|
1987
|
-
<span class="ruby-keyword kw">end</span>
|
1988
|
-
</pre>
|
1989
|
-
</div>
|
1990
|
-
</div>
|
1991
|
-
</div>
|
1992
|
-
<div class="method">
|
1993
|
-
<div class="title">
|
1994
|
-
<a name="M000134"></a><b>update_keys</b>( {|| ...}
|
1995
|
-
</div>
|
1996
|
-
<div class="description">
|
1997
|
-
<p>
|
1998
|
-
Iterate over hash updating just the keys.
|
1999
|
-
</p>
|
2000
|
-
<pre>
|
2001
|
-
h = {:a=>1, :b=>2}
|
2002
|
-
h.update_keys{ |k| "#{k}!" }
|
2003
|
-
h #=> { "a!"=>1, "b!"=>2 }
|
2004
|
-
</pre>
|
2005
|
-
<p>
|
2006
|
-
CREDIT: Trans
|
2007
|
-
</p>
|
2008
|
-
</div>
|
2009
|
-
<div class="sourcecode">
|
2010
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000134_source')" id="l_M000134_source">+</a> ]</p>
|
2011
|
-
<div id="M000134_source" class="dyn-source">
|
2012
|
-
<pre>
|
2013
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/update_keys.rb, line 11</span>
|
2014
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">update_keys</span> <span class="ruby-comment cmt">#:yield:</span>
|
2015
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
|
2016
|
-
<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">old_key</span><span class="ruby-operator">|</span> <span class="ruby-identifier">store</span>(<span class="ruby-keyword kw">yield</span>(<span class="ruby-identifier">old_key</span>), <span class="ruby-identifier">delete</span>(<span class="ruby-identifier">old_key</span>)) }
|
2017
|
-
<span class="ruby-keyword kw">else</span>
|
2018
|
-
<span class="ruby-identifier">to_enum</span>(<span class="ruby-identifier">:update_keys</span>)
|
2019
|
-
<span class="ruby-keyword kw">end</span>
|
2020
|
-
<span class="ruby-keyword kw">end</span>
|
2021
|
-
</pre>
|
2022
|
-
</div>
|
2023
|
-
</div>
|
2024
|
-
</div>
|
2025
|
-
<div class="method">
|
2026
|
-
<div class="title">
|
2027
|
-
<a name="M000081"></a><b>update_values</b>( {|| ...}
|
2028
|
-
</div>
|
2029
|
-
<div class="description">
|
2030
|
-
<p>
|
2031
|
-
Iterate over hash updating just the values.
|
2032
|
-
</p>
|
2033
|
-
<pre>
|
2034
|
-
h = {:a=>1, :b=>2}
|
2035
|
-
h.update_values{ |v| v+1 }
|
2036
|
-
h #=> { a:=>2, :b=>3 }
|
2037
|
-
</pre>
|
2038
|
-
<p>
|
2039
|
-
CREDIT: Trans
|
2040
|
-
</p>
|
2041
|
-
</div>
|
2042
|
-
<div class="sourcecode">
|
2043
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000081_source')" id="l_M000081_source">+</a> ]</p>
|
2044
|
-
<div id="M000081_source" class="dyn-source">
|
2045
|
-
<pre>
|
2046
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/update_values.rb, line 11</span>
|
2047
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">update_values</span> <span class="ruby-comment cmt">#:yield:</span>
|
2048
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
|
2049
|
-
<span class="ruby-identifier">each</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">store</span>(<span class="ruby-identifier">k</span>, <span class="ruby-keyword kw">yield</span>(<span class="ruby-identifier">v</span>)) }
|
2050
|
-
<span class="ruby-keyword kw">else</span>
|
2051
|
-
<span class="ruby-identifier">to_enum</span>(<span class="ruby-identifier">:update_values</span>)
|
2052
|
-
<span class="ruby-keyword kw">end</span>
|
2053
|
-
<span class="ruby-keyword kw">end</span>
|
2054
|
-
</pre>
|
2055
|
-
</div>
|
2056
|
-
</div>
|
2057
|
-
</div>
|
2058
|
-
<div class="method">
|
2059
|
-
<div class="title">
|
2060
|
-
<a name="M000118"></a><b>weave</b>(h)
|
2061
|
-
</div>
|
2062
|
-
<div class="description">
|
2063
|
-
<p>
|
2064
|
-
Weave is a very uniqe hash operator. I is designed to merge to complex
|
2065
|
-
hashes in according to sensible, regular pattern. The effect is akin to
|
2066
|
-
inheritance.
|
2067
|
-
</p>
|
2068
|
-
<p>
|
2069
|
-
Two hashes are weaved together to produce a new hash. The two hashes need
|
2070
|
-
to be compatible according to the following rules for each node:
|
2071
|
-
</p>
|
2072
|
-
<pre>
|
2073
|
-
<tt>
|
2074
|
-
hash, hash => hash (recursive +)
|
2075
|
-
hash, array => error
|
2076
|
-
hash, value => error
|
2077
|
-
array, hash => error
|
2078
|
-
array, array => array + array
|
2079
|
-
array, value => array << value
|
2080
|
-
value, hash => error
|
2081
|
-
value, array => array.unshift(valueB)
|
2082
|
-
value1, value2 => value2
|
2083
|
-
</tt>
|
2084
|
-
</pre>
|
2085
|
-
<p>
|
2086
|
-
Here is a basic example:
|
2087
|
-
</p>
|
2088
|
-
<pre>
|
2089
|
-
h1 = { :a => 1, :b => [ 1 ], :c => { :x => 1 } }
|
2090
|
-
=> {:b=>[1], :c=>{:x=>1}, :a=>1}
|
2091
|
-
|
2092
|
-
h2 = { :a => 2, :b => [ 2 ], :c => { :x => 2 } }
|
2093
|
-
=> {:b=>[2], :c=>{:x=>2}, :a=>2}
|
2094
|
-
|
2095
|
-
h1.weave(h2)
|
2096
|
-
=> {:b=>[1, 2], :c=>{:x=>2}, :a=>2}
|
2097
|
-
</pre>
|
2098
|
-
<p>
|
2099
|
-
Weave follows the most expected pattern of unifying two complex hashes. It
|
2100
|
-
is especially useful for implementing overridable configuration schemes.
|
2101
|
-
</p>
|
2102
|
-
<p>
|
2103
|
-
CREDIT: Thomas Sawyer
|
2104
|
-
</p>
|
2105
|
-
</div>
|
2106
|
-
<div class="sourcecode">
|
2107
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000118_source')" id="l_M000118_source">+</a> ]</p>
|
2108
|
-
<div id="M000118_source" class="dyn-source">
|
2109
|
-
<pre>
|
2110
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/weave.rb, line 40</span>
|
2111
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">weave</span>(<span class="ruby-identifier">h</span>)
|
2112
|
-
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">"Hash expected"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">h</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Hash</span>)
|
2113
|
-
<span class="ruby-identifier">s</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">clone</span>
|
2114
|
-
<span class="ruby-identifier">h</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">node</span><span class="ruby-operator">|</span>
|
2115
|
-
<span class="ruby-identifier">node_is_hash</span> = <span class="ruby-identifier">node</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Hash</span>)
|
2116
|
-
<span class="ruby-identifier">node_is_array</span> = <span class="ruby-identifier">node</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Array</span>)
|
2117
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">s</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">k</span>)
|
2118
|
-
<span class="ruby-identifier">self_node_is_hash</span> = <span class="ruby-identifier">s</span>[<span class="ruby-identifier">k</span>].<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Hash</span>)
|
2119
|
-
<span class="ruby-identifier">self_node_is_array</span> = <span class="ruby-identifier">s</span>[<span class="ruby-identifier">k</span>].<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Array</span>)
|
2120
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">self_node_is_hash</span>
|
2121
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">node_is_hash</span>
|
2122
|
-
<span class="ruby-identifier">s</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">s</span>[<span class="ruby-identifier">k</span>].<span class="ruby-identifier">weave</span>(<span class="ruby-identifier">node</span>)
|
2123
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">node_is_array</span>
|
2124
|
-
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">'Incompatible hash addition'</span> <span class="ruby-comment cmt">#self[k] = node</span>
|
2125
|
-
<span class="ruby-keyword kw">else</span>
|
2126
|
-
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">'Incompatible hash addition'</span> <span class="ruby-comment cmt">#self[k] = node</span>
|
2127
|
-
<span class="ruby-keyword kw">end</span>
|
2128
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">self_node_is_array</span>
|
2129
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">node_is_hash</span>
|
2130
|
-
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">'Incompatible hash addition'</span> <span class="ruby-comment cmt">#self[k] = node</span>
|
2131
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">node_is_array</span>
|
2132
|
-
<span class="ruby-identifier">s</span>[<span class="ruby-identifier">k</span>] <span class="ruby-operator">+=</span> <span class="ruby-identifier">node</span>
|
2133
|
-
<span class="ruby-keyword kw">else</span>
|
2134
|
-
<span class="ruby-identifier">s</span>[<span class="ruby-identifier">k</span>] <span class="ruby-operator"><<</span> <span class="ruby-identifier">node</span>
|
2135
|
-
<span class="ruby-keyword kw">end</span>
|
2136
|
-
<span class="ruby-keyword kw">else</span>
|
2137
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">node_is_hash</span>
|
2138
|
-
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">'Incompatible hash addition'</span> <span class="ruby-comment cmt">#self[k] = node</span>
|
2139
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">node_is_array</span>
|
2140
|
-
<span class="ruby-identifier">s</span>[<span class="ruby-identifier">k</span>].<span class="ruby-identifier">unshift</span>( <span class="ruby-identifier">node</span> )
|
2141
|
-
<span class="ruby-keyword kw">else</span>
|
2142
|
-
<span class="ruby-identifier">s</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">node</span>
|
2143
|
-
<span class="ruby-keyword kw">end</span>
|
2144
|
-
<span class="ruby-keyword kw">end</span>
|
2145
|
-
<span class="ruby-keyword kw">else</span>
|
2146
|
-
<span class="ruby-identifier">s</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">node</span>
|
2147
|
-
<span class="ruby-keyword kw">end</span>
|
2148
|
-
}
|
2149
|
-
<span class="ruby-identifier">s</span>
|
2150
|
-
<span class="ruby-keyword kw">end</span>
|
2151
|
-
</pre>
|
2152
|
-
</div>
|
2153
|
-
</div>
|
2154
|
-
</div>
|
2155
|
-
<div class="method">
|
2156
|
-
<div class="title">
|
2157
|
-
<a name="M000100"></a><b>|</b>(other)
|
2158
|
-
</div>
|
2159
|
-
<div class="description">
|
2160
|
-
<p>
|
2161
|
-
Operator for <a href="Hash.html#M000095">reverse_merge</a>.
|
2162
|
-
</p>
|
2163
|
-
<p>
|
2164
|
-
CREDIT: Trans
|
2165
|
-
</p>
|
2166
|
-
</div>
|
2167
|
-
<div class="sourcecode">
|
2168
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000100_source')" id="l_M000100_source">+</a> ]</p>
|
2169
|
-
<div id="M000100_source" class="dyn-source">
|
2170
|
-
<pre>
|
2171
|
-
<span class="ruby-comment cmt"># File lib/core/facets/hash/op_or.rb, line 7</span>
|
2172
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-operator">|</span>(<span class="ruby-identifier">other</span>)
|
2173
|
-
<span class="ruby-identifier">other</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-keyword kw">self</span>)
|
2174
|
-
<span class="ruby-keyword kw">end</span>
|
2175
|
-
</pre>
|
2176
|
-
</div>
|
2177
|
-
</div>
|
2178
|
-
</div>
|
2179
|
-
</div>
|
2180
|
-
|
2181
|
-
</div>
|
2182
|
-
|
2183
|
-
</body>
|
2184
|
-
</html>
|