Class: Hash

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

Instance Method Summary collapse

Instance Method Details

#key(search_value) ⇒ Object

Return a key based on a search value. Returns nil if nothing found



3
4
5
6
7
8
9
10
# File 'lib/monkey_patches/hash.rb', line 3

def key(search_value)
  self.each do |key, value|
    if value == search_value
      return key
    end
  end
  return nil
end