Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/mash.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#stringify_keys ⇒ Object
Returns a duplicate of the current hash with all of the keys converted to strings.
-
#stringify_keys! ⇒ Object
Converts all of the keys to strings.
-
#to_mash ⇒ Object
Returns a new Mash initialized from this Hash.
Instance Method Details
#stringify_keys ⇒ Object
Returns a duplicate of the current hash with all of the keys converted to strings.
214 215 216 |
# File 'lib/mash.rb', line 214 def stringify_keys dup.stringify_keys! end |
#stringify_keys! ⇒ Object
Converts all of the keys to strings
219 220 221 222 223 224 225 226 227 |
# File 'lib/mash.rb', line 219 def stringify_keys! keys.each{|k| v = delete(k) self[k.to_s] = v v.stringify_keys! if v.is_a?(Hash) v.each{|p| p.stringify_keys! if p.is_a?(Hash)} if v.is_a?(Array) } self end |