Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/hashy.rb

Instance Method Summary collapse

Instance Method Details

#map_keyObject



8
9
10
# File 'lib/hashy.rb', line 8

def map_key
  each_with_object({}) { |(k, v), h| h[yield(k)] = v }
end

#map_pair(&block) ⇒ Object



4
5
6
# File 'lib/hashy.rb', line 4

def map_pair &block
  Hash[map &block]
end

#map_valueObject



12
13
14
# File 'lib/hashy.rb', line 12

def map_value
  each_with_object({}) { |(k, v), h| h[k] = yield(v) }
end