Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/hash_transform.rb
Instance Method Summary collapse
Instance Method Details
#map_keys(&block) ⇒ Object
11 12 13 |
# File 'lib/hash_transform.rb', line 11 def map_keys(&block) dup.map_keys! &block end |
#map_keys! ⇒ Object
5 6 7 8 |
# File 'lib/hash_transform.rb', line 5 def map_keys! keys.each { |key| self[yield(key)] = delete key } self end |
#map_values(&block) ⇒ Object
22 23 24 |
# File 'lib/hash_transform.rb', line 22 def map_values(&block) dup.map_values! &block end |
#map_values! ⇒ Object
16 17 18 19 |
# File 'lib/hash_transform.rb', line 16 def map_values! each { |key, value| self[key] = yield(value) } self end |