Module: Geoloco

Defined in:
lib/geoloco.rb,
lib/geoloco/version.rb,
lib/geoloco/geometry.rb,
lib/geoloco/location.rb,
lib/geoloco/adapters/fake.rb,
lib/geoloco/adapters/google.rb,
lib/geoloco/adapters/tomtom.rb

Overview

Geoloco is a multi-adpater geolocation gem, with error handling and test stubs

Defined Under Namespace

Modules: Adapters Classes: Error, Forbidden, Geometry, Location, UnknownAdapter

Constant Summary collapse

VERSION =
'1.0.0'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configObject



36
37
38
# File 'lib/geoloco.rb', line 36

def config
  @config || {}
end

.default_adapterObject



32
33
34
# File 'lib/geoloco.rb', line 32

def default_adapter
  @default_adapter || :google
end

.httpObject



40
41
42
# File 'lib/geoloco.rb', line 40

def http
  @http || HTTParty
end

Class Method Details

.geocode(query, adapter: default_adapter, **options) ⇒ Object

Geocodes a given query using the given adapter and options

Parameters:

  • query (String)

    the query to geocode

  • adapter (String, Symbol) (defaults to: default_adapter)

    the adapter to use

Raises:



52
53
54
55
# File 'lib/geoloco.rb', line 52

def geocode(query, adapter: default_adapter, **options)
  adapter_config = config.fetch(adapter, {}).merge(options)
  geocoder(adapter).geocode(query, **adapter_config)
end