Class: ReverseGeocode
- Inherits:
-
Object
- Object
- ReverseGeocode
- Defined in:
- lib/reverse_geocode.rb
Defined Under Namespace
Classes: GeocodeError
Class Attribute Summary collapse
-
.api_key ⇒ Object
Returns the value of attribute api_key.
Instance Attribute Summary collapse
-
#lat ⇒ Object
readonly
Returns the value of attribute lat.
-
#long ⇒ Object
readonly
Returns the value of attribute long.
Instance Method Summary collapse
- #address ⇒ Object
- #city ⇒ Object
- #county ⇒ Object
-
#initialize(lat, long) ⇒ ReverseGeocode
constructor
A new instance of ReverseGeocode.
- #response ⇒ Object
- #state ⇒ Object
- #street ⇒ Object
- #zip ⇒ Object
Constructor Details
#initialize(lat, long) ⇒ ReverseGeocode
Returns a new instance of ReverseGeocode.
26 27 28 29 |
# File 'lib/reverse_geocode.rb', line 26 def initialize(lat, long) raise ArgumentError, "Latitude and longitude required" unless lat && long @lat, @long = lat, long end |
Class Attribute Details
.api_key ⇒ Object
Returns the value of attribute api_key.
23 24 25 |
# File 'lib/reverse_geocode.rb', line 23 def api_key @api_key end |
Instance Attribute Details
#lat ⇒ Object (readonly)
Returns the value of attribute lat.
25 26 27 |
# File 'lib/reverse_geocode.rb', line 25 def lat @lat end |
#long ⇒ Object (readonly)
Returns the value of attribute long.
25 26 27 |
# File 'lib/reverse_geocode.rb', line 25 def long @long end |
Instance Method Details
#address ⇒ Object
35 36 37 |
# File 'lib/reverse_geocode.rb', line 35 def address @address ||= first_placemark/'address' end |
#city ⇒ Object
51 52 53 |
# File 'lib/reverse_geocode.rb', line 51 def city @city ||= placemark[1]/'AddressDetails'/'Country'/'AdministrativeArea'/'Locality'/'LocalityName' end |
#county ⇒ Object
55 56 57 |
# File 'lib/reverse_geocode.rb', line 55 def county @county ||= (placemark[3]/'AddressDetails'/'Country'/'AdministrativeArea'/'AddressLine').first end |
#response ⇒ Object
31 32 33 |
# File 'lib/reverse_geocode.rb', line 31 def response @response ||= handle_response end |
#state ⇒ Object
43 44 45 |
# File 'lib/reverse_geocode.rb', line 43 def state @state ||= first_administrative_area/'AdministrativeAreaName' end |
#street ⇒ Object
39 40 41 |
# File 'lib/reverse_geocode.rb', line 39 def street @street ||= first_administrative_area/'Thoroughfare'/'ThoroughfareName' end |
#zip ⇒ Object
47 48 49 |
# File 'lib/reverse_geocode.rb', line 47 def zip @zip ||= first_administrative_area/'PostalCode'/'PostalCodeNumber' end |