Class: Geocoder::Lookup::Base
- Inherits:
-
Object
- Object
- Geocoder::Lookup::Base
- Defined in:
- lib/geocoder/lookups/base.rb
Instance Method Summary collapse
-
#map_link_url(coordinates) ⇒ Object
Return the URL for a map of the given coordinates.
-
#search(query) ⇒ Object
Query the geocoding API and return a Geocoder::Result object.
Instance Method Details
#map_link_url(coordinates) ⇒ Object
Return the URL for a map of the given coordinates.
Not necessarily implemented by all subclasses as only some lookups also provide maps.
45 46 47 |
# File 'lib/geocoder/lookups/base.rb', line 45 def map_link_url(coordinates) nil end |
#search(query) ⇒ Object
Query the geocoding API and return a Geocoder::Result object. Returns nil
on timeout or error.
Takes a search string (eg: “Mississippi Coast Coliseumf, Biloxi, MS”, “205.128.54.202”) for geocoding, or coordinates (latitude, longitude) for reverse geocoding. Returns an array of Geocoder::Result
s.
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/geocoder/lookups/base.rb', line 25 def search(query) # if coordinates given as string, turn into array query = query.split(/\s*,\s*/) if coordinates?(query) if query.is_a?(Array) reverse = true query = query.join(',') else reverse = false end results(query, reverse).map{ |r| result_class.new(r) } end |