Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/extended_hash_methods.rb
Instance Method Summary collapse
Instance Method Details
#invert_and_group ⇒ Object
6 7 8 9 10 |
# File 'lib/extended_hash_methods.rb', line 6 def invert_and_group self.values.uniq.map do |value| [value, keys_by_value(value)] end.to_h end |
#keys_by_value(value) ⇒ Object
2 3 4 |
# File 'lib/extended_hash_methods.rb', line 2 def keys_by_value(value) self.select { |_, v| v == value }.keys end |