Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- app/cyclid/monkey_patches.rb
Overview
Add two methods to Hash
Direct Known Subclasses
Instance Method Summary collapse
-
#%(other) ⇒ Object
Interpolate the data in the ctx hash into any String values.
- #hmap ⇒ Object
Instance Method Details
#%(other) ⇒ Object
Interpolate the data in the ctx hash into any String values
12 13 14 15 16 17 18 19 20 |
# File 'app/cyclid/monkey_patches.rb', line 12 def %(other) hmap do |key, value| if value.is_a? String { key => value ** other } else { key => value } end end end |
#hmap ⇒ Object
5 6 7 8 9 |
# File 'app/cyclid/monkey_patches.rb', line 5 def hmap inject({}) do |hash, (k, v)| hash.merge(yield(k, v)) end end |