immutable-ruby 0.0.1 → 0.1.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.
- checksums.yaml +5 -5
- data/lib/immutable/core_ext/enumerable.rb +1 -1
- data/lib/immutable/core_ext/io.rb +1 -1
- data/lib/immutable/core_ext.rb +2 -2
- data/lib/immutable/deque.rb +50 -15
- data/lib/immutable/enumerable.rb +19 -10
- data/lib/immutable/hash.rb +128 -28
- data/lib/immutable/list.rb +48 -48
- data/lib/immutable/nested.rb +10 -7
- data/lib/immutable/set.rb +30 -30
- data/lib/immutable/sorted_set.rb +77 -37
- data/lib/immutable/trie.rb +21 -29
- data/lib/immutable/vector.rb +61 -46
- data/lib/immutable/version.rb +1 -1
- data/lib/immutable.rb +9 -9
- metadata +44 -687
- data/spec/fixtures/io_spec.txt +0 -3
- data/spec/lib/immutable/core_ext/array_spec.rb +0 -13
- data/spec/lib/immutable/core_ext/enumerable_spec.rb +0 -29
- data/spec/lib/immutable/core_ext/io_spec.rb +0 -28
- data/spec/lib/immutable/deque/clear_spec.rb +0 -33
- data/spec/lib/immutable/deque/construction_spec.rb +0 -29
- data/spec/lib/immutable/deque/copying_spec.rb +0 -19
- data/spec/lib/immutable/deque/dequeue_spec.rb +0 -34
- data/spec/lib/immutable/deque/empty_spec.rb +0 -39
- data/spec/lib/immutable/deque/enqueue_spec.rb +0 -27
- data/spec/lib/immutable/deque/first_spec.rb +0 -17
- data/spec/lib/immutable/deque/inspect_spec.rb +0 -23
- data/spec/lib/immutable/deque/last_spec.rb +0 -17
- data/spec/lib/immutable/deque/marshal_spec.rb +0 -33
- data/spec/lib/immutable/deque/new_spec.rb +0 -43
- data/spec/lib/immutable/deque/pop_spec.rb +0 -36
- data/spec/lib/immutable/deque/pretty_print_spec.rb +0 -23
- data/spec/lib/immutable/deque/push_spec.rb +0 -36
- data/spec/lib/immutable/deque/random_modification_spec.rb +0 -33
- data/spec/lib/immutable/deque/shift_spec.rb +0 -29
- data/spec/lib/immutable/deque/size_spec.rb +0 -19
- data/spec/lib/immutable/deque/to_a_spec.rb +0 -26
- data/spec/lib/immutable/deque/to_ary_spec.rb +0 -35
- data/spec/lib/immutable/deque/to_list_spec.rb +0 -24
- data/spec/lib/immutable/deque/unshift_spec.rb +0 -30
- data/spec/lib/immutable/hash/all_spec.rb +0 -53
- data/spec/lib/immutable/hash/any_spec.rb +0 -53
- data/spec/lib/immutable/hash/assoc_spec.rb +0 -51
- data/spec/lib/immutable/hash/clear_spec.rb +0 -42
- data/spec/lib/immutable/hash/construction_spec.rb +0 -38
- data/spec/lib/immutable/hash/copying_spec.rb +0 -13
- data/spec/lib/immutable/hash/default_proc_spec.rb +0 -72
- data/spec/lib/immutable/hash/delete_spec.rb +0 -39
- data/spec/lib/immutable/hash/each_spec.rb +0 -77
- data/spec/lib/immutable/hash/each_with_index_spec.rb +0 -29
- data/spec/lib/immutable/hash/empty_spec.rb +0 -43
- data/spec/lib/immutable/hash/eql_spec.rb +0 -69
- data/spec/lib/immutable/hash/except_spec.rb +0 -42
- data/spec/lib/immutable/hash/fetch_spec.rb +0 -57
- data/spec/lib/immutable/hash/find_spec.rb +0 -43
- data/spec/lib/immutable/hash/flat_map_spec.rb +0 -35
- data/spec/lib/immutable/hash/flatten_spec.rb +0 -98
- data/spec/lib/immutable/hash/get_spec.rb +0 -79
- data/spec/lib/immutable/hash/has_key_spec.rb +0 -31
- data/spec/lib/immutable/hash/has_value_spec.rb +0 -27
- data/spec/lib/immutable/hash/hash_spec.rb +0 -29
- data/spec/lib/immutable/hash/inspect_spec.rb +0 -30
- data/spec/lib/immutable/hash/invert_spec.rb +0 -30
- data/spec/lib/immutable/hash/key_spec.rb +0 -27
- data/spec/lib/immutable/hash/keys_spec.rb +0 -15
- data/spec/lib/immutable/hash/map_spec.rb +0 -45
- data/spec/lib/immutable/hash/marshal_spec.rb +0 -28
- data/spec/lib/immutable/hash/merge_spec.rb +0 -82
- data/spec/lib/immutable/hash/min_max_spec.rb +0 -45
- data/spec/lib/immutable/hash/new_spec.rb +0 -70
- data/spec/lib/immutable/hash/none_spec.rb +0 -48
- data/spec/lib/immutable/hash/partition_spec.rb +0 -35
- data/spec/lib/immutable/hash/pretty_print_spec.rb +0 -34
- data/spec/lib/immutable/hash/put_spec.rb +0 -102
- data/spec/lib/immutable/hash/reduce_spec.rb +0 -35
- data/spec/lib/immutable/hash/reject_spec.rb +0 -61
- data/spec/lib/immutable/hash/reverse_each_spec.rb +0 -27
- data/spec/lib/immutable/hash/sample_spec.rb +0 -13
- data/spec/lib/immutable/hash/select_spec.rb +0 -57
- data/spec/lib/immutable/hash/size_spec.rb +0 -51
- data/spec/lib/immutable/hash/slice_spec.rb +0 -44
- data/spec/lib/immutable/hash/sort_spec.rb +0 -26
- data/spec/lib/immutable/hash/store_spec.rb +0 -75
- data/spec/lib/immutable/hash/take_spec.rb +0 -35
- data/spec/lib/immutable/hash/to_a_spec.rb +0 -13
- data/spec/lib/immutable/hash/to_hash_spec.rb +0 -21
- data/spec/lib/immutable/hash/update_in_spec.rb +0 -79
- data/spec/lib/immutable/hash/values_at_spec.rb +0 -13
- data/spec/lib/immutable/hash/values_spec.rb +0 -23
- data/spec/lib/immutable/list/add_spec.rb +0 -25
- data/spec/lib/immutable/list/all_spec.rb +0 -57
- data/spec/lib/immutable/list/any_spec.rb +0 -49
- data/spec/lib/immutable/list/append_spec.rb +0 -38
- data/spec/lib/immutable/list/at_spec.rb +0 -29
- data/spec/lib/immutable/list/break_spec.rb +0 -69
- data/spec/lib/immutable/list/cadr_spec.rb +0 -38
- data/spec/lib/immutable/list/chunk_spec.rb +0 -28
- data/spec/lib/immutable/list/clear_spec.rb +0 -24
- data/spec/lib/immutable/list/combination_spec.rb +0 -33
- data/spec/lib/immutable/list/compact_spec.rb +0 -34
- data/spec/lib/immutable/list/compare_spec.rb +0 -30
- data/spec/lib/immutable/list/cons_spec.rb +0 -25
- data/spec/lib/immutable/list/construction_spec.rb +0 -110
- data/spec/lib/immutable/list/copying_spec.rb +0 -19
- data/spec/lib/immutable/list/count_spec.rb +0 -36
- data/spec/lib/immutable/list/cycle_spec.rb +0 -28
- data/spec/lib/immutable/list/delete_at_spec.rb +0 -18
- data/spec/lib/immutable/list/delete_spec.rb +0 -16
- data/spec/lib/immutable/list/drop_spec.rb +0 -30
- data/spec/lib/immutable/list/drop_while_spec.rb +0 -38
- data/spec/lib/immutable/list/each_slice_spec.rb +0 -51
- data/spec/lib/immutable/list/each_spec.rb +0 -40
- data/spec/lib/immutable/list/each_with_index_spec.rb +0 -28
- data/spec/lib/immutable/list/empty_spec.rb +0 -23
- data/spec/lib/immutable/list/eql_spec.rb +0 -61
- data/spec/lib/immutable/list/fill_spec.rb +0 -49
- data/spec/lib/immutable/list/find_all_spec.rb +0 -70
- data/spec/lib/immutable/list/find_index_spec.rb +0 -35
- data/spec/lib/immutable/list/find_spec.rb +0 -42
- data/spec/lib/immutable/list/flat_map_spec.rb +0 -51
- data/spec/lib/immutable/list/flatten_spec.rb +0 -30
- data/spec/lib/immutable/list/grep_spec.rb +0 -46
- data/spec/lib/immutable/list/group_by_spec.rb +0 -41
- data/spec/lib/immutable/list/hash_spec.rb +0 -21
- data/spec/lib/immutable/list/head_spec.rb +0 -19
- data/spec/lib/immutable/list/include_spec.rb +0 -35
- data/spec/lib/immutable/list/index_spec.rb +0 -33
- data/spec/lib/immutable/list/indices_spec.rb +0 -61
- data/spec/lib/immutable/list/init_spec.rb +0 -28
- data/spec/lib/immutable/list/inits_spec.rb +0 -28
- data/spec/lib/immutable/list/insert_spec.rb +0 -46
- data/spec/lib/immutable/list/inspect_spec.rb +0 -29
- data/spec/lib/immutable/list/intersperse_spec.rb +0 -28
- data/spec/lib/immutable/list/join_spec.rb +0 -63
- data/spec/lib/immutable/list/last_spec.rb +0 -23
- data/spec/lib/immutable/list/ltlt_spec.rb +0 -19
- data/spec/lib/immutable/list/map_spec.rb +0 -45
- data/spec/lib/immutable/list/maximum_spec.rb +0 -39
- data/spec/lib/immutable/list/merge_by_spec.rb +0 -51
- data/spec/lib/immutable/list/merge_spec.rb +0 -59
- data/spec/lib/immutable/list/minimum_spec.rb +0 -39
- data/spec/lib/immutable/list/multithreading_spec.rb +0 -47
- data/spec/lib/immutable/list/none_spec.rb +0 -47
- data/spec/lib/immutable/list/one_spec.rb +0 -49
- data/spec/lib/immutable/list/partition_spec.rb +0 -115
- data/spec/lib/immutable/list/permutation_spec.rb +0 -55
- data/spec/lib/immutable/list/pop_spec.rb +0 -25
- data/spec/lib/immutable/list/product_spec.rb +0 -23
- data/spec/lib/immutable/list/reduce_spec.rb +0 -53
- data/spec/lib/immutable/list/reject_spec.rb +0 -45
- data/spec/lib/immutable/list/reverse_spec.rb +0 -34
- data/spec/lib/immutable/list/rotate_spec.rb +0 -36
- data/spec/lib/immutable/list/sample_spec.rb +0 -13
- data/spec/lib/immutable/list/select_spec.rb +0 -70
- data/spec/lib/immutable/list/size_spec.rb +0 -25
- data/spec/lib/immutable/list/slice_spec.rb +0 -229
- data/spec/lib/immutable/list/sorting_spec.rb +0 -46
- data/spec/lib/immutable/list/span_spec.rb +0 -76
- data/spec/lib/immutable/list/split_at_spec.rb +0 -43
- data/spec/lib/immutable/list/subsequences_spec.rb +0 -23
- data/spec/lib/immutable/list/sum_spec.rb +0 -23
- data/spec/lib/immutable/list/tail_spec.rb +0 -30
- data/spec/lib/immutable/list/tails_spec.rb +0 -28
- data/spec/lib/immutable/list/take_spec.rb +0 -30
- data/spec/lib/immutable/list/take_while_spec.rb +0 -46
- data/spec/lib/immutable/list/to_a_spec.rb +0 -39
- data/spec/lib/immutable/list/to_ary_spec.rb +0 -41
- data/spec/lib/immutable/list/to_list_spec.rb +0 -19
- data/spec/lib/immutable/list/to_set_spec.rb +0 -17
- data/spec/lib/immutable/list/transpose_spec.rb +0 -19
- data/spec/lib/immutable/list/union_spec.rb +0 -31
- data/spec/lib/immutable/list/uniq_spec.rb +0 -35
- data/spec/lib/immutable/list/zip_spec.rb +0 -23
- data/spec/lib/immutable/nested/construction_spec.rb +0 -95
- data/spec/lib/immutable/set/add_spec.rb +0 -75
- data/spec/lib/immutable/set/all_spec.rb +0 -51
- data/spec/lib/immutable/set/any_spec.rb +0 -51
- data/spec/lib/immutable/set/clear_spec.rb +0 -33
- data/spec/lib/immutable/set/compact_spec.rb +0 -30
- data/spec/lib/immutable/set/construction_spec.rb +0 -18
- data/spec/lib/immutable/set/copying_spec.rb +0 -13
- data/spec/lib/immutable/set/count_spec.rb +0 -36
- data/spec/lib/immutable/set/delete_spec.rb +0 -71
- data/spec/lib/immutable/set/difference_spec.rb +0 -49
- data/spec/lib/immutable/set/disjoint_spec.rb +0 -25
- data/spec/lib/immutable/set/each_spec.rb +0 -45
- data/spec/lib/immutable/set/empty_spec.rb +0 -44
- data/spec/lib/immutable/set/eqeq_spec.rb +0 -103
- data/spec/lib/immutable/set/eql_spec.rb +0 -109
- data/spec/lib/immutable/set/exclusion_spec.rb +0 -47
- data/spec/lib/immutable/set/find_spec.rb +0 -35
- data/spec/lib/immutable/set/first_spec.rb +0 -28
- data/spec/lib/immutable/set/flatten_spec.rb +0 -46
- data/spec/lib/immutable/set/grep_spec.rb +0 -57
- data/spec/lib/immutable/set/group_by_spec.rb +0 -59
- data/spec/lib/immutable/set/hash_spec.rb +0 -22
- data/spec/lib/immutable/set/include_spec.rb +0 -60
- data/spec/lib/immutable/set/inspect_spec.rb +0 -47
- data/spec/lib/immutable/set/intersect_spec.rb +0 -25
- data/spec/lib/immutable/set/intersection_spec.rb +0 -52
- data/spec/lib/immutable/set/join_spec.rb +0 -64
- data/spec/lib/immutable/set/map_spec.rb +0 -59
- data/spec/lib/immutable/set/marshal_spec.rb +0 -28
- data/spec/lib/immutable/set/maximum_spec.rb +0 -36
- data/spec/lib/immutable/set/minimum_spec.rb +0 -36
- data/spec/lib/immutable/set/new_spec.rb +0 -53
- data/spec/lib/immutable/set/none_spec.rb +0 -47
- data/spec/lib/immutable/set/one_spec.rb +0 -47
- data/spec/lib/immutable/set/partition_spec.rb +0 -52
- data/spec/lib/immutable/set/product_spec.rb +0 -23
- data/spec/lib/immutable/set/reduce_spec.rb +0 -55
- data/spec/lib/immutable/set/reject_spec.rb +0 -50
- data/spec/lib/immutable/set/reverse_each_spec.rb +0 -38
- data/spec/lib/immutable/set/sample_spec.rb +0 -13
- data/spec/lib/immutable/set/select_spec.rb +0 -73
- data/spec/lib/immutable/set/size_spec.rb +0 -17
- data/spec/lib/immutable/set/sorting_spec.rb +0 -59
- data/spec/lib/immutable/set/subset_spec.rb +0 -51
- data/spec/lib/immutable/set/sum_spec.rb +0 -23
- data/spec/lib/immutable/set/superset_spec.rb +0 -51
- data/spec/lib/immutable/set/to_a_spec.rb +0 -30
- data/spec/lib/immutable/set/to_list_spec.rb +0 -35
- data/spec/lib/immutable/set/to_set_spec.rb +0 -19
- data/spec/lib/immutable/set/union_spec.rb +0 -63
- data/spec/lib/immutable/sorted_set/above_spec.rb +0 -51
- data/spec/lib/immutable/sorted_set/add_spec.rb +0 -62
- data/spec/lib/immutable/sorted_set/at_spec.rb +0 -24
- data/spec/lib/immutable/sorted_set/below_spec.rb +0 -51
- data/spec/lib/immutable/sorted_set/between_spec.rb +0 -51
- data/spec/lib/immutable/sorted_set/clear_spec.rb +0 -43
- data/spec/lib/immutable/sorted_set/copying_spec.rb +0 -20
- data/spec/lib/immutable/sorted_set/delete_at_spec.rb +0 -18
- data/spec/lib/immutable/sorted_set/delete_spec.rb +0 -89
- data/spec/lib/immutable/sorted_set/difference_spec.rb +0 -22
- data/spec/lib/immutable/sorted_set/disjoint_spec.rb +0 -25
- data/spec/lib/immutable/sorted_set/drop_spec.rb +0 -55
- data/spec/lib/immutable/sorted_set/drop_while_spec.rb +0 -34
- data/spec/lib/immutable/sorted_set/each_spec.rb +0 -28
- data/spec/lib/immutable/sorted_set/empty_spec.rb +0 -34
- data/spec/lib/immutable/sorted_set/eql_spec.rb +0 -120
- data/spec/lib/immutable/sorted_set/exclusion_spec.rb +0 -22
- data/spec/lib/immutable/sorted_set/fetch_spec.rb +0 -64
- data/spec/lib/immutable/sorted_set/find_index_spec.rb +0 -40
- data/spec/lib/immutable/sorted_set/first_spec.rb +0 -18
- data/spec/lib/immutable/sorted_set/from_spec.rb +0 -51
- data/spec/lib/immutable/sorted_set/group_by_spec.rb +0 -57
- data/spec/lib/immutable/sorted_set/include_spec.rb +0 -23
- data/spec/lib/immutable/sorted_set/inspect_spec.rb +0 -37
- data/spec/lib/immutable/sorted_set/intersect_spec.rb +0 -25
- data/spec/lib/immutable/sorted_set/intersection_spec.rb +0 -28
- data/spec/lib/immutable/sorted_set/last_spec.rb +0 -36
- data/spec/lib/immutable/sorted_set/map_spec.rb +0 -43
- data/spec/lib/immutable/sorted_set/marshal_spec.rb +0 -36
- data/spec/lib/immutable/sorted_set/maximum_spec.rb +0 -36
- data/spec/lib/immutable/sorted_set/minimum_spec.rb +0 -19
- data/spec/lib/immutable/sorted_set/new_spec.rb +0 -71
- data/spec/lib/immutable/sorted_set/reverse_each_spec.rb +0 -28
- data/spec/lib/immutable/sorted_set/sample_spec.rb +0 -13
- data/spec/lib/immutable/sorted_set/select_spec.rb +0 -61
- data/spec/lib/immutable/sorted_set/size_spec.rb +0 -17
- data/spec/lib/immutable/sorted_set/slice_spec.rb +0 -256
- data/spec/lib/immutable/sorted_set/sorting_spec.rb +0 -44
- data/spec/lib/immutable/sorted_set/subset_spec.rb +0 -47
- data/spec/lib/immutable/sorted_set/superset_spec.rb +0 -47
- data/spec/lib/immutable/sorted_set/take_spec.rb +0 -54
- data/spec/lib/immutable/sorted_set/take_while_spec.rb +0 -33
- data/spec/lib/immutable/sorted_set/to_set_spec.rb +0 -17
- data/spec/lib/immutable/sorted_set/union_spec.rb +0 -27
- data/spec/lib/immutable/sorted_set/up_to_spec.rb +0 -52
- data/spec/lib/immutable/sorted_set/values_at_spec.rb +0 -33
- data/spec/lib/immutable/vector/add_spec.rb +0 -67
- data/spec/lib/immutable/vector/any_spec.rb +0 -69
- data/spec/lib/immutable/vector/assoc_spec.rb +0 -45
- data/spec/lib/immutable/vector/bsearch_spec.rb +0 -65
- data/spec/lib/immutable/vector/clear_spec.rb +0 -33
- data/spec/lib/immutable/vector/combination_spec.rb +0 -81
- data/spec/lib/immutable/vector/compact_spec.rb +0 -29
- data/spec/lib/immutable/vector/compare_spec.rb +0 -31
- data/spec/lib/immutable/vector/concat_spec.rb +0 -34
- data/spec/lib/immutable/vector/copying_spec.rb +0 -20
- data/spec/lib/immutable/vector/count_spec.rb +0 -17
- data/spec/lib/immutable/vector/delete_at_spec.rb +0 -53
- data/spec/lib/immutable/vector/delete_spec.rb +0 -30
- data/spec/lib/immutable/vector/drop_spec.rb +0 -41
- data/spec/lib/immutable/vector/drop_while_spec.rb +0 -54
- data/spec/lib/immutable/vector/each_index_spec.rb +0 -40
- data/spec/lib/immutable/vector/each_spec.rb +0 -44
- data/spec/lib/immutable/vector/each_with_index_spec.rb +0 -39
- data/spec/lib/immutable/vector/empty_spec.rb +0 -41
- data/spec/lib/immutable/vector/eql_spec.rb +0 -76
- data/spec/lib/immutable/vector/fetch_spec.rb +0 -64
- data/spec/lib/immutable/vector/fill_spec.rb +0 -88
- data/spec/lib/immutable/vector/first_spec.rb +0 -18
- data/spec/lib/immutable/vector/flat_map_spec.rb +0 -50
- data/spec/lib/immutable/vector/flatten_spec.rb +0 -58
- data/spec/lib/immutable/vector/get_spec.rb +0 -74
- data/spec/lib/immutable/vector/group_by_spec.rb +0 -57
- data/spec/lib/immutable/vector/include_spec.rb +0 -30
- data/spec/lib/immutable/vector/insert_spec.rb +0 -68
- data/spec/lib/immutable/vector/inspect_spec.rb +0 -49
- data/spec/lib/immutable/vector/join_spec.rb +0 -58
- data/spec/lib/immutable/vector/last_spec.rb +0 -45
- data/spec/lib/immutable/vector/length_spec.rb +0 -45
- data/spec/lib/immutable/vector/ltlt_spec.rb +0 -65
- data/spec/lib/immutable/vector/map_spec.rb +0 -51
- data/spec/lib/immutable/vector/marshal_spec.rb +0 -31
- data/spec/lib/immutable/vector/maximum_spec.rb +0 -33
- data/spec/lib/immutable/vector/minimum_spec.rb +0 -33
- data/spec/lib/immutable/vector/multiply_spec.rb +0 -47
- data/spec/lib/immutable/vector/new_spec.rb +0 -50
- data/spec/lib/immutable/vector/partition_spec.rb +0 -52
- data/spec/lib/immutable/vector/permutation_spec.rb +0 -91
- data/spec/lib/immutable/vector/pop_spec.rb +0 -26
- data/spec/lib/immutable/vector/product_spec.rb +0 -70
- data/spec/lib/immutable/vector/reduce_spec.rb +0 -55
- data/spec/lib/immutable/vector/reject_spec.rb +0 -43
- data/spec/lib/immutable/vector/repeated_combination_spec.rb +0 -77
- data/spec/lib/immutable/vector/repeated_permutation_spec.rb +0 -93
- data/spec/lib/immutable/vector/reverse_each_spec.rb +0 -31
- data/spec/lib/immutable/vector/reverse_spec.rb +0 -21
- data/spec/lib/immutable/vector/rindex_spec.rb +0 -36
- data/spec/lib/immutable/vector/rotate_spec.rb +0 -73
- data/spec/lib/immutable/vector/sample_spec.rb +0 -13
- data/spec/lib/immutable/vector/select_spec.rb +0 -63
- data/spec/lib/immutable/vector/set_spec.rb +0 -174
- data/spec/lib/immutable/vector/shift_spec.rb +0 -27
- data/spec/lib/immutable/vector/shuffle_spec.rb +0 -43
- data/spec/lib/immutable/vector/slice_spec.rb +0 -240
- data/spec/lib/immutable/vector/sorting_spec.rb +0 -56
- data/spec/lib/immutable/vector/sum_spec.rb +0 -17
- data/spec/lib/immutable/vector/take_spec.rb +0 -42
- data/spec/lib/immutable/vector/take_while_spec.rb +0 -34
- data/spec/lib/immutable/vector/to_a_spec.rb +0 -41
- data/spec/lib/immutable/vector/to_ary_spec.rb +0 -34
- data/spec/lib/immutable/vector/to_list_spec.rb +0 -30
- data/spec/lib/immutable/vector/to_set_spec.rb +0 -21
- data/spec/lib/immutable/vector/transpose_spec.rb +0 -48
- data/spec/lib/immutable/vector/uniq_spec.rb +0 -76
- data/spec/lib/immutable/vector/unshift_spec.rb +0 -28
- data/spec/lib/immutable/vector/update_in_spec.rb +0 -82
- data/spec/lib/immutable/vector/values_at_spec.rb +0 -33
- data/spec/lib/immutable/vector/zip_spec.rb +0 -57
- data/spec/lib/load_spec.rb +0 -42
- data/spec/spec_helper.rb +0 -92
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 54e4768953f4e1a9afbfc0d8496bdb563ae850419c905ea4dce78b560c88da3c
|
4
|
+
data.tar.gz: 9237a022ed3107aad98adfaed510cbd4b76367b06aab7a2d6a1f8dc2d6d3c911
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7aa2208347fcce032af7b0885cb5088ea7d93573dd54c59fbebf7d98bd962be8880533c3c0fabe92fb7cfc5eddf1a9cc06cb60a0180ee55507d09dde7b2a0396
|
7
|
+
data.tar.gz: f10991e1881c42941d9723eb0acc569126b06716273852089c7f25a3bf2e5fefc25e1d5c767682dbb75d88a52da9dc12aee90627c7e1a92cf513f586aab3ef42
|
data/lib/immutable/core_ext.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'immutable/core_ext/enumerable'
|
2
|
+
require 'immutable/core_ext/io'
|
data/lib/immutable/deque.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'immutable/list'
|
2
2
|
|
3
3
|
module Immutable
|
4
4
|
|
@@ -48,7 +48,7 @@ module Immutable
|
|
48
48
|
#
|
49
49
|
# @return [Deque]
|
50
50
|
def empty
|
51
|
-
@empty ||=
|
51
|
+
@empty ||= new
|
52
52
|
end
|
53
53
|
|
54
54
|
# "Raw" allocation of a new `Deque`. Used internally to create a new
|
@@ -86,7 +86,7 @@ module Immutable
|
|
86
86
|
def size
|
87
87
|
@front.size + @rear.size
|
88
88
|
end
|
89
|
-
alias
|
89
|
+
alias length size
|
90
90
|
|
91
91
|
# Return the first item in the `Deque`. If the deque is empty, return `nil`.
|
92
92
|
#
|
@@ -110,10 +110,38 @@ module Immutable
|
|
110
110
|
@front.last # memoize?
|
111
111
|
end
|
112
112
|
|
113
|
+
# Return a new `Deque` with elements rotated by `n` positions.
|
114
|
+
# A positive rotation moves elements to the right, negative to the left, and 0 is a no-op.
|
115
|
+
#
|
116
|
+
# @example
|
117
|
+
# Immutable::Deque["A", "B", "C"].rotate(1)
|
118
|
+
# # => Immutable::Deque["C", "A", "B"]
|
119
|
+
# Immutable::Deque["A", "B", "C"].rotate(-1)
|
120
|
+
# # => Immutable::Deque["B", "C", "A"]
|
121
|
+
#
|
122
|
+
# @param n [Integer] number of positions to move elements by
|
123
|
+
# @return [Deque]
|
124
|
+
def rotate(n)
|
125
|
+
return self.class.empty if empty?
|
126
|
+
|
127
|
+
n %= size
|
128
|
+
return self if n == 0
|
129
|
+
|
130
|
+
a, b = @front, @rear
|
131
|
+
|
132
|
+
if b.size >= n
|
133
|
+
n.times { a = a.cons(b.head); b = b.tail }
|
134
|
+
else
|
135
|
+
(size - n).times { b = b.cons(a.head); a = a.tail }
|
136
|
+
end
|
137
|
+
|
138
|
+
self.class.alloc(a, b)
|
139
|
+
end
|
140
|
+
|
113
141
|
# Return a new `Deque` with `item` added at the end.
|
114
142
|
#
|
115
143
|
# @example
|
116
|
-
# Immutable::Deque["A", "B", "C"].
|
144
|
+
# Immutable::Deque["A", "B", "C"].push("Z")
|
117
145
|
# # => Immutable::Deque["A", "B", "C", "Z"]
|
118
146
|
#
|
119
147
|
# @param item [Object] The item to add
|
@@ -121,7 +149,7 @@ module Immutable
|
|
121
149
|
def push(item)
|
122
150
|
self.class.alloc(@front, @rear.cons(item))
|
123
151
|
end
|
124
|
-
alias
|
152
|
+
alias enqueue push
|
125
153
|
|
126
154
|
# Return a new `Deque` with the last item removed.
|
127
155
|
#
|
@@ -170,7 +198,7 @@ module Immutable
|
|
170
198
|
|
171
199
|
self.class.alloc(front.tail, rear)
|
172
200
|
end
|
173
|
-
alias
|
201
|
+
alias dequeue shift
|
174
202
|
|
175
203
|
# Return an empty `Deque` instance, of the same class as this one. Useful if you
|
176
204
|
# have multiple subclasses of `Deque` and want to treat them polymorphically.
|
@@ -180,6 +208,13 @@ module Immutable
|
|
180
208
|
self.class.empty
|
181
209
|
end
|
182
210
|
|
211
|
+
# Return a new `Deque` with the same items, but in reverse order.
|
212
|
+
#
|
213
|
+
# @return [Deque]
|
214
|
+
def reverse
|
215
|
+
self.class.alloc(@rear, @front)
|
216
|
+
end
|
217
|
+
|
183
218
|
# Return true if `other` has the same type and contents as this `Deque`.
|
184
219
|
#
|
185
220
|
# @param other [Object] The collection to compare with
|
@@ -188,15 +223,15 @@ module Immutable
|
|
188
223
|
return true if other.equal?(self)
|
189
224
|
instance_of?(other.class) && to_ary.eql?(other.to_ary)
|
190
225
|
end
|
191
|
-
alias
|
226
|
+
alias == eql?
|
192
227
|
|
193
228
|
# Return an `Array` with the same elements, in the same order.
|
194
229
|
# @return [Array]
|
195
230
|
def to_a
|
196
|
-
@front.to_a.concat(@rear.to_a.tap
|
231
|
+
@front.to_a.concat(@rear.to_a.tap(&:reverse!))
|
197
232
|
end
|
198
|
-
alias
|
199
|
-
alias
|
233
|
+
alias entries to_a
|
234
|
+
alias to_ary to_a
|
200
235
|
|
201
236
|
# Return a {List} with the same elements, in the same order.
|
202
237
|
# @return [Immutable::List]
|
@@ -213,8 +248,8 @@ module Immutable
|
|
213
248
|
result = "#{self.class}["
|
214
249
|
i = 0
|
215
250
|
@front.each { |obj| result << ', ' if i > 0; result << obj.inspect; i += 1 }
|
216
|
-
@rear.to_a.tap
|
217
|
-
result <<
|
251
|
+
@rear.to_a.tap(&:reverse!).each { |obj| result << ', ' if i > 0; result << obj.inspect; i += 1 }
|
252
|
+
result << ']'
|
218
253
|
end
|
219
254
|
|
220
255
|
# Return `self`. Since this is an immutable object duplicates are
|
@@ -223,13 +258,13 @@ module Immutable
|
|
223
258
|
def dup
|
224
259
|
self
|
225
260
|
end
|
226
|
-
alias
|
261
|
+
alias clone dup
|
227
262
|
|
228
263
|
# @private
|
229
264
|
def pretty_print(pp)
|
230
|
-
pp.group(1, "#{self.class}[",
|
265
|
+
pp.group(1, "#{self.class}[", ']') do
|
231
266
|
pp.breakable ''
|
232
|
-
pp.seplist(
|
267
|
+
pp.seplist(to_a) { |obj| obj.pretty_print(pp) }
|
233
268
|
end
|
234
269
|
end
|
235
270
|
|
data/lib/immutable/enumerable.rb
CHANGED
@@ -15,7 +15,7 @@ module Immutable
|
|
15
15
|
return enum_for(:reject) if not block_given?
|
16
16
|
select { |item| !yield(item) }
|
17
17
|
end
|
18
|
-
alias
|
18
|
+
alias delete_if reject
|
19
19
|
|
20
20
|
# Return a new collection with all `nil` elements removed.
|
21
21
|
def compact
|
@@ -30,6 +30,15 @@ module Immutable
|
|
30
30
|
result
|
31
31
|
end
|
32
32
|
|
33
|
+
# Search the collection for elements which are not `#===` to `item`. Yield
|
34
|
+
# them to the optional code block if provided, and return them as a new
|
35
|
+
# collection.
|
36
|
+
def grep_v(pattern, &block)
|
37
|
+
result = select { |item| !(pattern === item) }
|
38
|
+
result = result.map(&block) if block_given?
|
39
|
+
result
|
40
|
+
end
|
41
|
+
|
33
42
|
# Yield all integers from 0 up to, but not including, the number of items in
|
34
43
|
# this collection. For collections which provide indexed access, these are all
|
35
44
|
# the valid, non-negative indices into the collection.
|
@@ -82,15 +91,15 @@ module Immutable
|
|
82
91
|
# Compare with `other`, and return 0, 1, or -1 if it is (respectively) equal to,
|
83
92
|
# greater than, or less than this collection.
|
84
93
|
def <=>(other)
|
85
|
-
return 0 if
|
86
|
-
enum1, enum2 =
|
94
|
+
return 0 if equal?(other)
|
95
|
+
enum1, enum2 = to_enum, other.to_enum
|
87
96
|
loop do
|
88
97
|
item1 = enum1.next
|
89
98
|
item2 = enum2.next
|
90
99
|
comp = (item1 <=> item2)
|
91
100
|
return comp if comp != 0
|
92
101
|
end
|
93
|
-
size1, size2 =
|
102
|
+
size1, size2 = size, other.size
|
94
103
|
return 0 if size1 == size2
|
95
104
|
size1 > size2 ? 1 : -1
|
96
105
|
end
|
@@ -98,14 +107,14 @@ module Immutable
|
|
98
107
|
# Return true if `other` contains the same elements, in the same order.
|
99
108
|
# @return [Boolean]
|
100
109
|
def ==(other)
|
101
|
-
|
110
|
+
eql?(other) || (other.respond_to?(:to_ary) && to_ary == other.to_ary)
|
102
111
|
end
|
103
112
|
|
104
113
|
# Convert all the elements into strings and join them together, separated by
|
105
114
|
# `separator`. By default, the `separator` is `$,`, the global default string
|
106
115
|
# separator, which is normally `nil`.
|
107
116
|
def join(separator = $,)
|
108
|
-
result =
|
117
|
+
result = ''
|
109
118
|
if separator
|
110
119
|
each_with_index { |obj, i| result << separator if i > 0; result << obj.to_s }
|
111
120
|
else
|
@@ -123,19 +132,19 @@ module Immutable
|
|
123
132
|
def inspect
|
124
133
|
result = "#{self.class}["
|
125
134
|
each_with_index { |obj, i| result << ', ' if i > 0; result << obj.inspect }
|
126
|
-
result <<
|
135
|
+
result << ']'
|
127
136
|
end
|
128
137
|
|
129
138
|
# @private
|
130
139
|
def pretty_print(pp)
|
131
|
-
pp.group(1, "#{self.class}[",
|
140
|
+
pp.group(1, "#{self.class}[", ']') do
|
132
141
|
pp.breakable ''
|
133
142
|
pp.seplist(self) { |obj| obj.pretty_print(pp) }
|
134
143
|
end
|
135
144
|
end
|
136
145
|
|
137
|
-
alias
|
138
|
-
alias
|
146
|
+
alias to_ary to_a
|
147
|
+
alias index find_index
|
139
148
|
|
140
149
|
## Compatibility fixes
|
141
150
|
|
data/lib/immutable/hash.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
1
|
+
require 'immutable/undefined'
|
2
|
+
require 'immutable/enumerable'
|
3
|
+
require 'immutable/trie'
|
4
|
+
require 'immutable/set'
|
5
|
+
require 'immutable/vector'
|
6
6
|
|
7
7
|
module Immutable
|
8
8
|
|
@@ -78,7 +78,7 @@ module Immutable
|
|
78
78
|
#
|
79
79
|
# @return [Hash]
|
80
80
|
def empty
|
81
|
-
@empty ||=
|
81
|
+
@empty ||= new
|
82
82
|
end
|
83
83
|
|
84
84
|
# "Raw" allocation of a new `Hash`. Used internally to create a new
|
@@ -119,7 +119,7 @@ module Immutable
|
|
119
119
|
def size
|
120
120
|
@trie.size
|
121
121
|
end
|
122
|
-
alias
|
122
|
+
alias length size
|
123
123
|
|
124
124
|
# Return `true` if this `Hash` contains no key/value pairs.
|
125
125
|
#
|
@@ -140,9 +140,9 @@ module Immutable
|
|
140
140
|
def key?(key)
|
141
141
|
@trie.key?(key)
|
142
142
|
end
|
143
|
-
alias
|
144
|
-
alias
|
145
|
-
alias
|
143
|
+
alias has_key? key?
|
144
|
+
alias include? key?
|
145
|
+
alias member? key?
|
146
146
|
|
147
147
|
# Return `true` if this `Hash` has one or more keys which map to the provided value.
|
148
148
|
#
|
@@ -155,7 +155,7 @@ module Immutable
|
|
155
155
|
each { |k,v| return true if value == v }
|
156
156
|
false
|
157
157
|
end
|
158
|
-
alias
|
158
|
+
alias has_value? value?
|
159
159
|
|
160
160
|
# Retrieve the value corresponding to the provided key object. If not found, and
|
161
161
|
# this `Hash` has a default block, the default block is called to provide the
|
@@ -182,7 +182,7 @@ module Immutable
|
|
182
182
|
@default.call(key)
|
183
183
|
end
|
184
184
|
end
|
185
|
-
alias
|
185
|
+
alias [] get
|
186
186
|
|
187
187
|
# Retrieve the value corresponding to the given key object, or use the provided
|
188
188
|
# default value or block, or otherwise raise a `KeyError`.
|
@@ -264,6 +264,12 @@ module Immutable
|
|
264
264
|
end
|
265
265
|
end
|
266
266
|
|
267
|
+
# @private
|
268
|
+
# @raise NoMethodError
|
269
|
+
def []=(*)
|
270
|
+
raise NoMethodError, "Immutable::Hash doesn't support `[]='; use `put' instead"
|
271
|
+
end
|
272
|
+
|
267
273
|
# Return a new `Hash` with a deeply nested value modified to the result of
|
268
274
|
# the given code block. When traversing the nested `Hash`es and `Vector`s,
|
269
275
|
# non-existing keys are created with empty `Hash` values.
|
@@ -287,7 +293,7 @@ module Immutable
|
|
287
293
|
# @return [Hash]
|
288
294
|
def update_in(*key_path, &block)
|
289
295
|
if key_path.empty?
|
290
|
-
raise ArgumentError,
|
296
|
+
raise ArgumentError, 'must have at least one key in path'
|
291
297
|
end
|
292
298
|
key = key_path[0]
|
293
299
|
if key_path.size == 1
|
@@ -342,7 +348,7 @@ module Immutable
|
|
342
348
|
@trie.each(&block)
|
343
349
|
self
|
344
350
|
end
|
345
|
-
alias
|
351
|
+
alias each_pair each
|
346
352
|
|
347
353
|
# Call the block once for each key/value pair in this `Hash`, passing the key/value
|
348
354
|
# pair as parameters. Iteration order will be the opposite of {#each}.
|
@@ -417,7 +423,7 @@ module Immutable
|
|
417
423
|
return self if empty?
|
418
424
|
self.class.new(super, &@default)
|
419
425
|
end
|
420
|
-
alias
|
426
|
+
alias collect map
|
421
427
|
|
422
428
|
# Return a new `Hash` with all the key/value pairs for which the block returns true.
|
423
429
|
#
|
@@ -433,8 +439,8 @@ module Immutable
|
|
433
439
|
return enum_for(:select) unless block_given?
|
434
440
|
derive_new_hash(@trie.select(&block))
|
435
441
|
end
|
436
|
-
alias
|
437
|
-
alias
|
442
|
+
alias find_all select
|
443
|
+
alias keep_if select
|
438
444
|
|
439
445
|
# Yield `[key, value]` pairs until one is found for which the block returns true.
|
440
446
|
# Return that `[key, value]` pair. If the block never returns true, return `nil`.
|
@@ -452,7 +458,7 @@ module Immutable
|
|
452
458
|
each { |entry| return entry if yield entry }
|
453
459
|
nil
|
454
460
|
end
|
455
|
-
alias
|
461
|
+
alias detect find
|
456
462
|
|
457
463
|
# Return a new `Hash` containing all the key/value pairs from this `Hash` and
|
458
464
|
# `other`. If no block is provided, the value for entries with colliding keys
|
@@ -479,7 +485,7 @@ module Immutable
|
|
479
485
|
def merge(other)
|
480
486
|
trie = if block_given?
|
481
487
|
other.reduce(@trie) do |trie, (key, value)|
|
482
|
-
if entry = trie.get(key)
|
488
|
+
if (entry = trie.get(key))
|
483
489
|
trie.put(key, yield(key, entry[1], value))
|
484
490
|
else
|
485
491
|
trie.put(key, value)
|
@@ -570,20 +576,54 @@ module Immutable
|
|
570
576
|
end
|
571
577
|
|
572
578
|
# Return a {Vector} of the values which correspond to the `wanted` keys.
|
573
|
-
# If any of the `wanted` keys are not present in this `Hash`,
|
579
|
+
# If any of the `wanted` keys are not present in this `Hash`, `nil` will be
|
580
|
+
# placed instead, or the result of the default proc (if one is defined),
|
581
|
+
# similar to the behavior of {#get}.
|
574
582
|
#
|
575
583
|
# @example
|
576
584
|
# h = Immutable::Hash["A" => 1, "B" => 2, "C" => 3]
|
577
|
-
# h.values_at("B", "A", "D") # => Immutable::Vector[2, 1]
|
585
|
+
# h.values_at("B", "A", "D") # => Immutable::Vector[2, 1, nil]
|
578
586
|
#
|
579
587
|
# @param wanted [Array] The keys to retrieve
|
580
588
|
# @return [Vector]
|
581
589
|
def values_at(*wanted)
|
582
|
-
|
583
|
-
|
590
|
+
Vector.new(wanted.map { |key| get(key) }.freeze)
|
591
|
+
end
|
592
|
+
|
593
|
+
# Return a {Vector} of the values which correspond to the `wanted` keys.
|
594
|
+
# If any of the `wanted` keys are not present in this `Hash`, raise `KeyError`
|
595
|
+
# exception.
|
596
|
+
#
|
597
|
+
# @example
|
598
|
+
# h = Immutable::Hash["A" => 1, "B" => 2, "C" => 3]
|
599
|
+
# h.fetch_values("C", "A") # => Immutable::Vector[3, 1]
|
600
|
+
# h.fetch_values("C", "Z") # => KeyError: key not found: "Z"
|
601
|
+
#
|
602
|
+
# @param wanted [Array] The keys to retrieve
|
603
|
+
# @return [Vector]
|
604
|
+
def fetch_values(*wanted)
|
605
|
+
array = wanted.map { |key| fetch(key) }
|
584
606
|
Vector.new(array.freeze)
|
585
607
|
end
|
586
608
|
|
609
|
+
# Return the value of successively indexing into a nested collection.
|
610
|
+
# If any of the keys is not present, return `nil`.
|
611
|
+
#
|
612
|
+
# @example
|
613
|
+
# h = Immutable::Hash[a: 9, b: Immutable::Hash[c: 'a', d: 4], e: nil]
|
614
|
+
# h.dig(:b, :c) # => "a"
|
615
|
+
# h.dig(:b, :f) # => nil
|
616
|
+
#
|
617
|
+
# @return [Object]
|
618
|
+
def dig(key, *rest)
|
619
|
+
value = self[key]
|
620
|
+
if rest.empty? || value.nil?
|
621
|
+
value
|
622
|
+
else
|
623
|
+
value.dig(*rest)
|
624
|
+
end
|
625
|
+
end
|
626
|
+
|
587
627
|
# Return a new {Set} containing the keys from this `Hash`.
|
588
628
|
#
|
589
629
|
# @example
|
@@ -731,7 +771,51 @@ module Immutable
|
|
731
771
|
# @param other [Object] The object to compare with
|
732
772
|
# @return [Boolean]
|
733
773
|
def ==(other)
|
734
|
-
|
774
|
+
eql?(other) || (other.respond_to?(:to_hash) && to_hash == other.to_hash)
|
775
|
+
end
|
776
|
+
|
777
|
+
# Return true if this `Hash` is a proper superset of `other`, which means
|
778
|
+
# all `other`'s keys are contained in this `Hash` with identical
|
779
|
+
# values, and the two hashes are not identical.
|
780
|
+
#
|
781
|
+
# @param other [Immutable::Hash] The object to compare with
|
782
|
+
# @return [Boolean]
|
783
|
+
def >(other)
|
784
|
+
self != other && self >= other
|
785
|
+
end
|
786
|
+
|
787
|
+
# Return true if this `Hash` is a superset of `other`, which means all
|
788
|
+
# `other`'s keys are contained in this `Hash` with identical values.
|
789
|
+
#
|
790
|
+
# @param other [Immutable::Hash] The object to compare with
|
791
|
+
# @return [Boolean]
|
792
|
+
def >=(other)
|
793
|
+
other.each do |key, value|
|
794
|
+
if self[key] != value
|
795
|
+
return false
|
796
|
+
end
|
797
|
+
end
|
798
|
+
true
|
799
|
+
end
|
800
|
+
|
801
|
+
# Return true if this `Hash` is a proper subset of `other`, which means all
|
802
|
+
# its keys are contained in `other` with the identical values, and the two
|
803
|
+
# hashes are not identical.
|
804
|
+
#
|
805
|
+
# @param other [Immutable::Hash] The object to compare with
|
806
|
+
# @return [Boolean]
|
807
|
+
def <(other)
|
808
|
+
other > self
|
809
|
+
end
|
810
|
+
|
811
|
+
# Return true if this `Hash` is a subset of `other`, which means all its
|
812
|
+
# keys are contained in `other` with the identical values, and the two
|
813
|
+
# hashes are not identical.
|
814
|
+
#
|
815
|
+
# @param other [Immutable::Hash] The object to compare with
|
816
|
+
# @return [Boolean]
|
817
|
+
def <=(other)
|
818
|
+
other >= self
|
735
819
|
end
|
736
820
|
|
737
821
|
# See `Object#hash`.
|
@@ -756,7 +840,7 @@ module Immutable
|
|
756
840
|
result << key.inspect << ' => ' << val.inspect
|
757
841
|
i += 1
|
758
842
|
end
|
759
|
-
result <<
|
843
|
+
result << ']'
|
760
844
|
end
|
761
845
|
|
762
846
|
# Return `self`. Since this is an immutable object duplicates are
|
@@ -765,7 +849,7 @@ module Immutable
|
|
765
849
|
def dup
|
766
850
|
self
|
767
851
|
end
|
768
|
-
alias
|
852
|
+
alias clone dup
|
769
853
|
|
770
854
|
# Allows this `Hash` to be printed at the `pry` console, or using `pp` (from the
|
771
855
|
# Ruby standard library), in a way which takes the amount of horizontal space on
|
@@ -774,7 +858,7 @@ module Immutable
|
|
774
858
|
#
|
775
859
|
# @private
|
776
860
|
def pretty_print(pp)
|
777
|
-
pp.group(1, "#{self.class}[",
|
861
|
+
pp.group(1, "#{self.class}[", ']') do
|
778
862
|
pp.breakable ''
|
779
863
|
pp.seplist(self, nil) do |key, val|
|
780
864
|
pp.group do
|
@@ -799,7 +883,23 @@ module Immutable
|
|
799
883
|
end
|
800
884
|
output
|
801
885
|
end
|
802
|
-
alias
|
886
|
+
alias to_h to_hash
|
887
|
+
|
888
|
+
# Return a `Proc` which accepts a key as an argument and returns the value.
|
889
|
+
# The `Proc` behaves like {#get} (when the key is missing, it returns nil or
|
890
|
+
# the result of the default proc).
|
891
|
+
#
|
892
|
+
# @example
|
893
|
+
# h = Immutable::Hash["A" => 1, "B" => 2, "C" => 3]
|
894
|
+
# h.to_proc.call("B")
|
895
|
+
# # => 2
|
896
|
+
# ["A", "C", "X"].map(&h) # The & is short for .to_proc in Ruby
|
897
|
+
# # => [1, 3, nil]
|
898
|
+
#
|
899
|
+
# @return [Proc]
|
900
|
+
def to_proc
|
901
|
+
lambda { |key| get(key) }
|
902
|
+
end
|
803
903
|
|
804
904
|
# @return [::Hash]
|
805
905
|
# @private
|