Class: Hash
Instance Method Summary collapse
- #stringify_keys ⇒ Object
- #stringify_keys! ⇒ Object
- #symbolize_keys ⇒ Object
- #symbolize_keys! ⇒ Object
- #to_param ⇒ Object
- #transform_keys ⇒ Object
- #transform_keys! ⇒ Object
Instance Method Details
#stringify_keys ⇒ Object
14 15 16 |
# File 'lib/small/hash.rb', line 14 def stringify_keys transform_keys(&:to_s) end |
#stringify_keys! ⇒ Object
18 19 20 |
# File 'lib/small/hash.rb', line 18 def stringify_keys! transform_keys!(&:to_s) end |
#symbolize_keys ⇒ Object
22 23 24 |
# File 'lib/small/hash.rb', line 22 def symbolize_keys transform_keys(&:to_sym) end |
#symbolize_keys! ⇒ Object
26 27 28 |
# File 'lib/small/hash.rb', line 26 def symbolize_keys! transform_keys!(&:to_sym) end |
#to_param ⇒ Object
30 31 32 |
# File 'lib/small/hash.rb', line 30 def to_param collect {|key, value| "#{key}=#{value}" }.sort * '&' end |
#transform_keys ⇒ Object
3 4 5 6 7 |
# File 'lib/small/hash.rb', line 3 def transform_keys result = {} keys.each {|key| result[(yield(key) rescue key)] = self[key] } result end |
#transform_keys! ⇒ Object
9 10 11 12 |
# File 'lib/small/hash.rb', line 9 def transform_keys! keys.each {|key| self[(yield(key) rescue key)] = delete(key)} self end |