Class: Hash
Instance Method Summary collapse
Instance Method Details
#hmap(&blk) ⇒ Object
3 4 5 |
# File 'lib/lab419/core/hash.rb', line 3 def hmap &blk Hash[ *map(&blk).flatten_once ] end |
#only(*keys) ⇒ Object
7 8 9 10 11 |
# File 'lib/lab419/core/hash.rb', line 7 def only *keys keys.inject Hash.new do | h, k | has_key?( k ) ? h.merge( k => self[k] ) : h end end |
#without(*keys) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/lab419/core/hash.rb', line 13 def without *keys dup.tap do | h | keys.each do | k | h.delete k end end end |