Class: ReverseGeocode
- Inherits:
-
Object
- Object
- ReverseGeocode
- Defined in:
- lib/reverse_geocode.rb
Defined Under Namespace
Classes: GeocodeError
Constant Summary collapse
- GOOGLE_URI =
"http://maps.google.com/maps/geo"
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.
28 29 30 31 |
# File 'lib/reverse_geocode.rb', line 28 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.
25 26 27 |
# File 'lib/reverse_geocode.rb', line 25 def api_key @api_key end |
Instance Attribute Details
#lat ⇒ Object (readonly)
Returns the value of attribute lat.
27 28 29 |
# File 'lib/reverse_geocode.rb', line 27 def lat @lat end |
#long ⇒ Object (readonly)
Returns the value of attribute long.
27 28 29 |
# File 'lib/reverse_geocode.rb', line 27 def long @long end |
Instance Method Details
#address ⇒ Object
37 38 39 |
# File 'lib/reverse_geocode.rb', line 37 def address @address ||= first_placemark/'address' end |
#city ⇒ Object
53 54 55 |
# File 'lib/reverse_geocode.rb', line 53 def city @city ||= (placemark_by_accuracy(4)/'AddressDetails'/'Country'/'AdministrativeArea'/'AddressLine').first end |
#county ⇒ Object
57 58 59 |
# File 'lib/reverse_geocode.rb', line 57 def county @county ||= (placemark_by_accuracy(3)/'AddressDetails'/'Country'/'AdministrativeArea'/'AddressLine').first end |
#response ⇒ Object
33 34 35 |
# File 'lib/reverse_geocode.rb', line 33 def response @response ||= handle_response end |
#state ⇒ Object
45 46 47 |
# File 'lib/reverse_geocode.rb', line 45 def state @state ||= first_administrative_area/'AdministrativeAreaName' end |
#street ⇒ Object
41 42 43 |
# File 'lib/reverse_geocode.rb', line 41 def street @street ||= first_administrative_area/'Thoroughfare'/'ThoroughfareName' end |
#zip ⇒ Object
49 50 51 |
# File 'lib/reverse_geocode.rb', line 49 def zip @zip ||= first_administrative_area/'PostalCode'/'PostalCodeNumber' end |