Class: Twofishes::Client
- Inherits:
-
Object
- Object
- Twofishes::Client
- Defined in:
- lib/twofishes/client.rb
Class Method Summary collapse
-
.geocode(location, options = {}) ⇒ Twofishes::Result
Geocodes a given string.
- .handle_response ⇒ Object
-
.reverse_geocode(coordinates, options = {}) ⇒ Twofishes::Result
Reverse geocodes lat/lng.
- .thrift_client ⇒ Object
Class Method Details
.geocode(location, options = {}) ⇒ Twofishes::Result
Geocodes a given string.
15 16 17 18 19 20 21 |
# File 'lib/twofishes/client.rb', line 15 def self.geocode(location, = {}) handle_response do [:query] = location request = Twofishes::GeocodeRequest.new() thrift_client.geocode(request) end end |
.handle_response ⇒ Object
48 49 50 51 52 |
# File 'lib/twofishes/client.rb', line 48 def self.handle_response Result.from_response(yield) rescue => e raise Twofishes::InvalidResponseError, e. end |
.reverse_geocode(coordinates, options = {}) ⇒ Twofishes::Result
Reverse geocodes lat/lng.
30 31 32 33 34 35 36 |
# File 'lib/twofishes/client.rb', line 30 def self.reverse_geocode(coordinates, = {}) handle_response do [:ll] = coordinates request = Twofishes::GeocodeRequest.new() thrift_client.reverseGeocode(request) end end |
.thrift_client ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/twofishes/client.rb', line 38 def self.thrift_client ThriftClient.new( Geocoder::Client, Twofishes.configuration.address, retries: Twofishes.configuration.retries, timeout: Twofishes.configuration.timeout, connect_timeout: Twofishes.configuration.connect_timeout ) end |