* gorillib/hashlike * gorillib/hashlike/slice * gorillib/hashlike/deep_dup * gorillib/hashlike/ * gorillib/hashlike/hashlike_via_accessors * gorillib/struct/acts_as_hash * gorillib/struct/iterates_as_hash h4. acts_as_hash * []= associates key with value * [] retrieves value associated with given key * delete removes that key and its association * keys enumeration of all keys having associations. * check for compatibility/semantics of Enumerable * has_key? true if an association exists for the given key. h4. hashlike Want chokepoints: keys - each, each_pair - each_value - reject! - delete_if - reject - select! - keep_if - each_key - key - has_key? - values_at - length, size - empty? * each keys.each{|k| yield [k, self[k]] } ; self * has_key? keys.include?(k) * length keys.length * size alias for length * empty? keys.empty? * each_pair alias for each * each_key keys.each{|k| yield k } * each_value each{|k,v| yield v } * key keys.find{|k| self[k] == val } * values_at in_keys.each{|k| self[k] if has_key?(k) } * values [].tap{|arr| each{|k,v| arr << v } } * to_hash {}.tap{|hsh| each{|k,v| hsh[k] = v } } * has_value? keys.any?{|k| self[k] == val } * value? alias for has_value? * include? alias for has_key? * key? alias for has_key? * member? alias for has_key? * update other_hash.each{|k,v| self[k] = (block_given? && has_key?(k) ? yield(k,v,self[k]) : v) } * merge! update * merge dup.merge! * reject! chgd = false ; each{|k,v| if yield(k,v) then delete(k); chgd = true ; end } chgd ? self : nil * select! chgd = false ; each{|k,v| if !yield(k,v) then delete(k); chgd = true ; end } chgd ? self : nil * delete_if: reject! ; return self * keep_if: select! ; return self * reject: self.dup.delete_if * fetch [] if has_key? else default else yield else raise KeyError * clear each_key{|k| delete(k) } * invert to_hash.invert #all?, #any?, #chunk, #collect, #collect_concat, #count, #cycle, #detect, #drop, #drop_while, #each_cons, #each_entry, #each_slice, #each_with_index, #each_with_object, #entries, #find, #find_all, #find_index, #first, #flat_map, #grep, #group_by, #inject, #map, #max, #max_by, #min, #min_by, #minmax, #minmax_by, #none?, #one?, #partition, #reduce, #reverse_each, #slice_before, #sort, #sort_by, #take, #take_while, #zip As opposed to hash, does *not* define default, default=, default_proc, default_proc=, replace, rehash, compare_by_identity compare_by_identity?, shift, flatten, h4. Configliere::DeepHash -- a magic hash - only allows handles as keys (only things that can be turned into symbols are interesting) - indifferent access - deep access, via the dotted hash * FancyHash * *gorillib/hash/compact* compact, compact!, compact_blank, compact_blank! * *gorrilib/hash/deep_compact* deep_compact, deep_compact! * *gorrilib/hash/deep_merge* deep_merge, deep_merge! * *gorillib/hash/keys* stringify_keys, stringify_keys!, symbolize_keys, symbolize_keys!, assert_valid_keys * *gorillib/hash/reverse_merge* reverse_merge, reverse_merge! * *gorillib/hash/tree_merge* tree_merge, tree_merge! * *gorillib/hash/slice* slice, slice!, extract! * *gorillib/hash/zip* Hash.zip * Receiver =========================================================================== =========================================================================== ?> [ :store, :delete, :keys, :each, :each_key, :each_value, :has_key?, :include?, :key?, :member?, :has_value?, :value?, :fetch, :length, :empty?, :to_hash, :values, :values_at, :merge, :update, :key, :invert, :reject!, :select!, :delete_if, :keep_if, :reject, :clear, :assoc, :rassoc].each{|m| puts `ri 'Hash##{m}'` }