Module: DaHuang::HashExt
- Defined in:
- lib/hash_ext.rb
Instance Method Summary collapse
Instance Method Details
#add(hash) ⇒ Object
3 4 5 |
# File 'lib/hash_ext.rb', line 3 def add(hash) hash.each{|a,b| self[a]=b} end |
#harvest(&block) ⇒ Object
13 14 15 16 17 |
# File 'lib/hash_ext.rb', line 13 def harvest(&block) a = select{|t,u| block.call(t,u)} delete_if{|t,u| block.call(t,u)} return a end |
#map_ary(&block) ⇒ Object
7 8 9 10 11 |
# File 'lib/hash_ext.rb', line 7 def map_ary(&block) val = [] self.each{|a,b| val.add block.call(a,b)} val end |
#reject_keys(ary) ⇒ Object
19 20 21 |
# File 'lib/hash_ext.rb', line 19 def reject_keys(ary) self.reject{|a,b| ary.include?(a)} end |