Class: Graticule::Geocoder::Yahoo

Inherits:
Base
  • Object
show all
Defined in:
lib/graticule/geocoder/yahoo.rb

Overview

Defined Under Namespace

Classes: Address, Error, Result

Constant Summary collapse

PRECISION =
{
  "country" => Precision::Country,
  "state"   => Precision::Region,
  "city"    => Precision::Locality,
  "zip+4"   => Precision::PostalCode,
  "zip+2"   => Precision::PostalCode,
  "zip"     => Precision::PostalCode,
  "street"  => Precision::Street,
  "address" => Precision::Address
}

Constants inherited from Base

Base::USER_AGENT

Instance Method Summary collapse

Constructor Details

#initialize(appid) ⇒ Yahoo

Web services initializer.

The appid is the Application ID that uniquely identifies your application. See: developer.yahoo.com/faq/index.html#appid

See developer.yahoo.com/search/rest.html



27
28
29
30
# File 'lib/graticule/geocoder/yahoo.rb', line 27

def initialize(appid)
  @appid = appid
  @url = URI.parse "http://api.local.yahoo.com/MapsService/V1/geocode"
end

Instance Method Details

#locate(address) ⇒ Object

Returns a Location for address.

The address can be any of:

  • city, state

  • city, state, zip

  • zip

  • street, city, state

  • street, city, state, zip

  • street, zip



41
42
43
44
45
# File 'lib/graticule/geocoder/yahoo.rb', line 41

def locate(address)
  location = (address.is_a?(String) ? address : location_from_params(address).to_s(:country => false))
  # yahoo pukes on line breaks
  get :location => location.gsub("\n", ', ')
end