Module Local
In: local.rb

Library for searching Yahoo Local

How to use:

Set Yahoo application id on the Local Module:

Local.app_id = ‘yourapikeygoeshere‘

Methods

search  

Classes and Modules

Class Local::Rating
Class Local::Request
Class Local::Response
Class Local::Result

Public Class methods

The search method takes two parameters Local.search(query, options)

example: Local.search("pizza" , {:zip => 32304, :results => 10, :sort => :relevance})

query is a string (what your searching for (eg: ‘pizza’))

more options:

  • :results - integer (default: 10, max: 20) - the number of results to return
  • :start - integer (default: 1) - the starting result position to return
  • :sort - string (‘relevance’ default , ‘title’ , ‘distance’, ‘rating’) - sorts the results by the chosen criteria
  • :radius - float - How far (in miles) from the specified location to search for the query terms. The default radius varies according to the location given.
  • :street - string - street name. the number is optional
  • :city - string - City name.
  • :state - string - The United States state. You can spell out the full state name or you can use the two-letter abbreviation
  • :zip - integer or <integer>-<integer> - The five-digit zip code, or the five-digit code plus four-digit extension. If this location contradicts the city and state specified, the zip code will be used for determining the location and the city and state will be ignored.
  • :location - string - This free field lets users enter any of the following:
      * city, state
      * city, state, zip
      * zip
      * street, city, state
      * street, city, state, zip
      * street, zip
    

If location is specified, it will take priority over the individual fields in determining the location for the query. City, state and zip will be ignored.

  • :latitude - float: -90 to 90 - The latitude of the starting location.
  • :longitude - float: -180 to 180 - The longitude of the starting location. If both latitude and longitude are specified, they will take priority over all other location data. If only one of latitude or longitude is specified, both will be ignored.

Returns a Response object

response = Local.search(‘pizza’, {:zip => 32304})

response.results will return an array of Result objects

eg: response.results.each {|result| puts result.title }

> Hungry Howies

> Pizza Hut

> Dominoes

[Validate]