Class: Hash
Instance Method Summary collapse
Instance Method Details
#filter ⇒ Object
2 3 4 5 6 7 8 |
# File 'lib/railings/extensions/hash.rb', line 2 def filter result = self.map do |k, v| r = yield v [k, r] end Hash[*result.flatten] end |
#filter!(&block) ⇒ Object
10 11 12 |
# File 'lib/railings/extensions/hash.rb', line 10 def filter! &block replace self.filter &block end |