Module: Slab::HashExt
- Defined in:
- lib/slab/hash.rb
Instance Method Summary collapse
Instance Method Details
#extract(*keys) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/slab/hash.rb', line 10 def extract(*keys) keys.inject({}) { |h, key| h[key] = self[key] if self.key?(key) h } end |
#hmap(&block) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/slab/hash.rb', line 3 def hmap(&block) self.inject({}) { |h, i| h[i[0]] = yield(i[0], i[1]) h } end |