Sha256: da9faf714aaee4cf47a48bfa5a9cbb70fc3f4a355f28eaa37c7379486e0f25a6
Contents?: true
Size: 460 Bytes
Versions: 3
Compression:
Stored size: 460 Bytes
Contents
class Hash def map_key_value(key_method, value_method = nil) value_method ||= key_method each.with_object({}) do |(k, v), new_hash| new_hash[k.send(key_method)] = v.send(value_method) end end def map_key(method) each.with_object({}) do |(k, v), new_hash| new_hash[k.send(method)] = v end end def map_value(method) each.with_object({}) do |(k, v), new_hash| new_hash[k] = v.send(method) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ruby_core_extensions-0.4.0 | lib/ruby_core_extensions/hash.rb |
ruby_core_extensions-0.3.0 | lib/ruby_core_extensions/hash.rb |
ruby_core_extensions-0.2.0 | lib/ruby_core_extensions/hash.rb |