Module: Geocoder
- Extended by:
- Geocoder
- Included in:
- Geocoder
- Defined in:
- lib/geocoder.rb,
lib/geocoder/cli.rb,
lib/geocoder/sql.rb,
lib/geocoder/cache.rb,
lib/geocoder/query.rb,
lib/geocoder/lookup.rb,
lib/geocoder/railtie.rb,
lib/geocoder/request.rb,
lib/geocoder/version.rb,
lib/geocoder/exceptions.rb,
lib/geocoder/models/base.rb,
lib/geocoder/stores/base.rb,
lib/geocoder/calculations.rb,
lib/geocoder/lookups/base.rb,
lib/geocoder/lookups/test.rb,
lib/geocoder/results/base.rb,
lib/geocoder/results/test.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,
lib/generators/geocoder/config/config_generator.rb
Defined Under Namespace
Modules: Calculations, Lookup, Model, Request, Result, Sql, Store Classes: Cache, Cli, ConfigGenerator, Configuration, ConfigurationError, Error, InvalidRequest, OverQueryLimitError, Query, Railtie, RequestDenied
Constant Summary collapse
- VERSION =
"1.1.5"
Class Method Summary collapse
-
.configure(&block) ⇒ Object
Provides convenient access to the Configuration singleton.
Instance Method Summary collapse
-
#address(query, options = {}) ⇒ 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, options = {}) ⇒ Object
Look up the coordinates of the given street or IP address.
-
#search(query, options = {}) ⇒ Object
Search for information about an address or a set of coordinates.
Class Method Details
.configure(&block) ⇒ Object
Provides convenient access to the Configuration singleton.
8 9 10 11 12 13 14 |
# File 'lib/geocoder/configuration.rb', line 8 def self.configure(&block) if block_given? block.call(Configuration.instance) else Configuration.instance end end |
Instance Method Details
#address(query, options = {}) ⇒ Object
Look up the address of the given coordinates ([lat,lon]) or IP address (string).
36 37 38 39 40 |
# File 'lib/geocoder.rb', line 36 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.
45 46 47 48 49 50 |
# File 'lib/geocoder.rb', line 45 def cache if @cache.nil? and store = Configuration.cache @cache = Cache.new(store, Configuration.cache_prefix) end @cache end |
#coordinates(address, options = {}) ⇒ Object
Look up the coordinates of the given street or IP address.
26 27 28 29 30 |
# File 'lib/geocoder.rb', line 26 def coordinates(address, = {}) if (results = search(address, )).size > 0 results.first.coordinates end end |