Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/langrove/ext/hash.rb
Instance Method Summary collapse
Instance Method Details
#sym_key_sub(sub = '_') ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/langrove/ext/hash.rb', line 4 def sym_key_sub( sub = '_' ) # # Substitutes all :symkeys with '_symkeys' # replace( inject({}) do |hash, (key,val) | val.sym_key_sub( sub ) if val.is_a?( Hash ) if key.is_a?( Symbol ) hash["#{sub}#{key.to_s}"] = val else hash[key] = val end hash end ) end |
#sym_key_usub(sub = '_') ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/langrove/ext/hash.rb', line 32 def sym_key_usub( sub = '_') replace( inject({}) do |hash, (key,val) | val.sym_key_usub( sub ) if val.is_a?( Hash ) if key[0] == '_' hash[key[1..-1].to_sym] = val else hash[key] = val end hash end ) end |