Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/hash_ext.rb
Instance Method Summary collapse
Instance Method Details
#numeric_values ⇒ Object
12 13 14 |
# File 'lib/hash_ext.rb', line 12 def numeric_values Hash[self.select { |k,v| v.is_a? Numeric }] end |
#prefix_keys(prefix) ⇒ Object
2 3 4 5 6 7 8 9 10 |
# File 'lib/hash_ext.rb', line 2 def prefix_keys ( prefix ) if block_given? Hash[self.map do |k,v| yield(k,v) ? ["#{prefix}#{k}", v] : [k,v] end] else Hash[self.map { |k,v| [ "#{prefix}#{k}", v] }] end end |