Class: YaYahooGeocode::Client

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

Constant Summary collapse

@@YAHOO_GEOCODE_ENDPOING =
'http://where.yahooapis.com/geocode'

Instance Method Summary collapse

Instance Method Details

#search_for_place(search_terms) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/ya_yahoo_geocode/client.rb', line 6

def search_for_place(search_terms)
  begin 
  url = @@YAHOO_GEOCODE_ENDPOING + '?q=' + URI::escape(search_terms)
  response = do_http_get(url)
  response_hash = Nori.parse(response)['ResultSet']
  rescue Exception => e 
    raise "Error searching for location: #{search_terms.inspect}.  Got error:  #{e.message}"
  end 
  handle_errors(response_hash, search_terms)
  select_match(response_hash)
end