Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/blix/rest/string_hash.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#transform_keys ⇒ Object
Returns a new hash with all keys converted using the block operation.
Instance Method Details
#transform_keys ⇒ Object
Returns a new hash with all keys converted using the block operation.
hash = { name: 'Rob', age: '28' }
hash.transform_keys{ |key| key.to_s.upcase }
# => {"NAME"=>"Rob", "AGE"=>"28"}
11 12 13 14 15 16 17 |
# File 'lib/blix/rest/string_hash.rb', line 11 def transform_keys result = {} each_key do |key| result[yield(key)] = self[key] end result end |