Class: Google::Geo::Address
- Inherits:
-
Object
- Object
- Google::Geo::Address
- Includes:
- Parser
- Defined in:
- lib/google/geo.rb
Overview
Represents locations returned in response to geocoding queries.
Instance Attribute Summary collapse
-
#accuracy ⇒ Object
readonly
An integer, Google’s rating of the accuracy of the supplied address.
-
#city ⇒ Object
(also: #locality)
readonly
Returns the value of attribute city.
-
#coordinates ⇒ Object
readonly
An array containing the standard three elements of a coordinate triple: latitude, longitude, elevation.
-
#country ⇒ Object
(also: #country_code)
readonly
Returns the value of attribute country.
-
#county ⇒ Object
(also: #subadministrative_area)
readonly
Returns the value of attribute county.
-
#elevation ⇒ Object
readonly
A float, the standard third element of a coordinate triple.
-
#full_address ⇒ Object
(also: #to_s)
readonly
All address attributes as one string, formatted by the service.
-
#latitude ⇒ Object
(also: #lat)
readonly
A float, the standard second element of a coordinate triple.
-
#longitude ⇒ Object
(also: #lng)
readonly
A float, the standard first element of a coordinate triple.
-
#query ⇒ Object
readonly
The address query sent to the service.
-
#state ⇒ Object
(also: #administrative_area)
readonly
Returns the value of attribute state.
-
#street ⇒ Object
(also: #thoroughfare)
readonly
Returns the value of attribute street.
-
#zip ⇒ Object
(also: #postal_code)
readonly
Returns the value of attribute zip.
Instance Method Summary collapse
-
#initialize(placemark, query) ⇒ Address
constructor
:nodoc.
Methods included from Parser
Constructor Details
#initialize(placemark, query) ⇒ Address
:nodoc
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/google/geo.rb', line 117 def initialize(placemark, query) #:nodoc @xml = placemark @query = query { :@street => :ThoroughfareName, :@city => :LocalityName, :@zip => :PostalCodeNumber, :@county => :SubAdministrativeAreaName, :@state => :AdministrativeAreaName, :@country => :CountryNameCode, :@full_address => :address }.each do |attribute, element| instance_variable_set(attribute, (fetch(element) rescue nil)) end @longitude, @latitude, @elevation = @coordinates = fetch(:coordinates).split(',').map { |x| x.to_f } @accuracy = fetch_accuracy end |
Instance Attribute Details
#accuracy ⇒ Object (readonly)
An integer, Google’s rating of the accuracy of the supplied address.
108 109 110 |
# File 'lib/google/geo.rb', line 108 def accuracy @accuracy end |
#city ⇒ Object (readonly) Also known as: locality
Returns the value of attribute city.
78 79 80 |
# File 'lib/google/geo.rb', line 78 def city @city end |
#coordinates ⇒ Object (readonly)
An array containing the standard three elements of a coordinate triple: latitude, longitude, elevation.
94 95 96 |
# File 'lib/google/geo.rb', line 94 def coordinates @coordinates end |
#country ⇒ Object (readonly) Also known as: country_code
Returns the value of attribute country.
90 91 92 |
# File 'lib/google/geo.rb', line 90 def country @country end |
#county ⇒ Object (readonly) Also known as: subadministrative_area
Returns the value of attribute county.
84 85 86 |
# File 'lib/google/geo.rb', line 84 def county @county end |
#elevation ⇒ Object (readonly)
A float, the standard third element of a coordinate triple.
105 106 107 |
# File 'lib/google/geo.rb', line 105 def elevation @elevation end |
#full_address ⇒ Object (readonly) Also known as: to_s
All address attributes as one string, formatted by the service.
111 112 113 |
# File 'lib/google/geo.rb', line 111 def full_address @full_address end |
#latitude ⇒ Object (readonly) Also known as: lat
A float, the standard second element of a coordinate triple.
101 102 103 |
# File 'lib/google/geo.rb', line 101 def latitude @latitude end |
#longitude ⇒ Object (readonly) Also known as: lng
A float, the standard first element of a coordinate triple.
97 98 99 |
# File 'lib/google/geo.rb', line 97 def longitude @longitude end |
#query ⇒ Object (readonly)
The address query sent to the service. i.e. The user input.
115 116 117 |
# File 'lib/google/geo.rb', line 115 def query @query end |
#state ⇒ Object (readonly) Also known as: administrative_area
Returns the value of attribute state.
87 88 89 |
# File 'lib/google/geo.rb', line 87 def state @state end |
#street ⇒ Object (readonly) Also known as: thoroughfare
Returns the value of attribute street.
75 76 77 |
# File 'lib/google/geo.rb', line 75 def street @street end |
#zip ⇒ Object (readonly) Also known as: postal_code
Returns the value of attribute zip.
81 82 83 |
# File 'lib/google/geo.rb', line 81 def zip @zip end |