Sha256: af9d393a2d33339b3f3dba8903f29075a8cf83e3ef7812f5f41e91909767150b
Contents?: true
Size: 785 Bytes
Versions: 2
Compression:
Stored size: 785 Bytes
Contents
class Hash # Returns a new hash less the given keys. def except(*less_keys) hash = dup less_keys.each{ |k| hash.delete(k) } hash end # Replaces hash with new hash less the given keys. # # h = {:a=>1, :b=>2, :c=>3} # h.except!(:a) #=> {:b=>2,:c=>3} # h #=> {:b=>2,:c=>3} # # Returns the hash. def except!(*rejected) rejected.each{ |k| delete(k) } self end # Replaces hash with new hash less the given keys. # This returns the hash of keys removed. # # h = {:a=>1, :b=>2, :c=>3} # h.except!(:a) #=> {:a=>1} # h #=> {:b=>2,:c=>3} # # Returns a Hash of the removed pairs. def remove!(*rejected) removed = {} rejected.each{ |k| removed[k] = delete(k) } removed end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
facets-glimmer-3.2.0 | lib/core/facets/hash/except.rb |
facets-3.1.0 | lib/core/facets/hash/except.rb |