Module: Geocoder
- Extended by:
- Geocoder
- Included in:
- Geocoder
- Defined in:
- lib/geocoder.rb,
lib/geocoder/cli.rb,
lib/geocoder/cache.rb,
lib/geocoder/railtie.rb,
lib/geocoder/request.rb,
lib/geocoder/version.rb,
lib/geocoder/models/base.rb,
lib/geocoder/stores/base.rb,
lib/geocoder/calculations.rb,
lib/geocoder/lookups/base.rb,
lib/geocoder/results/base.rb,
lib/geocoder/configuration.rb,
lib/geocoder/models/mongoid.rb,
lib/geocoder/models/mongo_base.rb,
lib/geocoder/models/mongo_mapper.rb,
lib/geocoder/models/active_record.rb
Defined Under Namespace
Modules: Calculations, Lookup, Model, Request, Result, Store Classes: Cache, Cli, Configuration, ConfigurationError, Error, Railtie
Constant Summary collapse
- VERSION =
"1.0.3"
Instance Method Summary collapse
-
#address(query) ⇒ Object
Look up the address of the given coordinates ([lat,lon]) or IP address (string).
-
#cache ⇒ Object
The working Cache object, or
nil
if none configured. -
#coordinates(address) ⇒ Object
Look up the coordinates of the given street or IP address.
-
#ip_lookups ⇒ Object
All IP address lookups, default first.
-
#search(query) ⇒ Object
Search for information about an address or a set of coordinates.
-
#street_lookups ⇒ Object
All street address lookups, default first.
-
#valid_lookups ⇒ Object
Array of valid Lookup names.
Instance Method Details
#address(query) ⇒ Object
Look up the address of the given coordinates ([lat,lon]) or IP address (string).
32 33 34 35 36 |
# File 'lib/geocoder.rb', line 32 def address(query) if (results = search(query)).size > 0 results.first.address end end |
#cache ⇒ Object
The working Cache object, or nil
if none configured.
41 42 43 44 45 46 |
# File 'lib/geocoder.rb', line 41 def cache if @cache.nil? and store = Configuration.cache @cache = Cache.new(store, Configuration.cache_prefix) end @cache end |
#coordinates(address) ⇒ Object
Look up the coordinates of the given street or IP address.
22 23 24 25 26 |
# File 'lib/geocoder.rb', line 22 def coordinates(address) if (results = search(address)).size > 0 results.first.coordinates end end |
#ip_lookups ⇒ Object
All IP address lookups, default first.
65 66 67 |
# File 'lib/geocoder.rb', line 65 def ip_lookups [:freegeoip] end |
#search(query) ⇒ Object
Search for information about an address or a set of coordinates.
15 16 17 |
# File 'lib/geocoder.rb', line 15 def search(query) blank_query?(query) ? [] : lookup(query).search(query) end |
#street_lookups ⇒ Object
All street address lookups, default first.
58 59 60 |
# File 'lib/geocoder.rb', line 58 def street_lookups [:google, :google_premier, :yahoo, :bing, :geocoder_ca, :yandex] end |
#valid_lookups ⇒ Object
Array of valid Lookup names.
51 52 53 |
# File 'lib/geocoder.rb', line 51 def valid_lookups street_lookups + ip_lookups end |