Hash#key returns the key for a given value

@hash = {"1"=>"one", "2"=>"two", "3"=>"three"}
@hash.key("one") #=> "1"

or nil if no such value exists:

@hash.key("four") #=> nil

To get either the value for a key, or the key for a value, you could use:

def finder(str)
  @hash[str] || @hash.key(str)
end

finder("1")   #=> "one"
finder("one") #=> "1"