Class: Drifter::Location
- Inherits:
-
Object
- Object
- Drifter::Location
- Defined in:
- lib/drifter/location.rb
Overview
Drifter.geocode() returns an array of Drifter::Location objects Depending on the geocoder used, Location objects are populated with a bunch of common attributes - see the docs for individual geocoders for a list of attributes they set:
Drifter::Geocoders::Google.geocode() Drifter::Geocoders::Yahoo.geocode()
Additional data returned by the geocoder can be accessed via the data() method
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#city ⇒ Object
Returns the value of attribute city.
-
#country ⇒ Object
Returns the value of attribute country.
-
#country_code ⇒ Object
Returns the value of attribute country_code.
-
#geocoder ⇒ Object
Returns the value of attribute geocoder.
-
#lat ⇒ Object
Returns the value of attribute lat.
-
#lng ⇒ Object
Returns the value of attribute lng.
-
#post_code ⇒ Object
Returns the value of attribute post_code.
-
#raw_data ⇒ Object
Returns the value of attribute raw_data.
-
#raw_data_format ⇒ Object
Returns the value of attribute raw_data_format.
-
#state ⇒ Object
Returns the value of attribute state.
-
#state_code ⇒ Object
Returns the value of attribute state_code.
Instance Method Summary collapse
-
#data ⇒ Object
returns a Hash containing the geocoder’s raw data.
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
18 19 20 |
# File 'lib/drifter/location.rb', line 18 def address @address end |
#city ⇒ Object
Returns the value of attribute city.
19 20 21 |
# File 'lib/drifter/location.rb', line 19 def city @city end |
#country ⇒ Object
Returns the value of attribute country.
23 24 25 |
# File 'lib/drifter/location.rb', line 23 def country @country end |
#country_code ⇒ Object
Returns the value of attribute country_code.
24 25 26 |
# File 'lib/drifter/location.rb', line 24 def country_code @country_code end |
#geocoder ⇒ Object
Returns the value of attribute geocoder.
16 17 18 |
# File 'lib/drifter/location.rb', line 16 def geocoder @geocoder end |
#lat ⇒ Object
Returns the value of attribute lat.
25 26 27 |
# File 'lib/drifter/location.rb', line 25 def lat @lat end |
#lng ⇒ Object
Returns the value of attribute lng.
26 27 28 |
# File 'lib/drifter/location.rb', line 26 def lng @lng end |
#post_code ⇒ Object
Returns the value of attribute post_code.
22 23 24 |
# File 'lib/drifter/location.rb', line 22 def post_code @post_code end |
#raw_data ⇒ Object
Returns the value of attribute raw_data.
14 15 16 |
# File 'lib/drifter/location.rb', line 14 def raw_data @raw_data end |
#raw_data_format ⇒ Object
Returns the value of attribute raw_data_format.
15 16 17 |
# File 'lib/drifter/location.rb', line 15 def raw_data_format @raw_data_format end |
#state ⇒ Object
Returns the value of attribute state.
20 21 22 |
# File 'lib/drifter/location.rb', line 20 def state @state end |
#state_code ⇒ Object
Returns the value of attribute state_code.
21 22 23 |
# File 'lib/drifter/location.rb', line 21 def state_code @state_code end |
Instance Method Details
#data ⇒ Object
returns a Hash containing the geocoder’s raw data. This is geocoder specific and you should read the provider’s docs to see what data they return in each geocoding response
31 32 33 34 35 36 37 |
# File 'lib/drifter/location.rb', line 31 def data @data ||= case raw_data_format when :hash then return raw_data when :json then return JSON.parse(raw_data) else nil end end |