Class: GeocoderGoogleResult
- Inherits:
-
Object
- Object
- GeocoderGoogleResult
- Defined in:
- app/models/geocoder_google_result.rb
Instance Attribute Summary collapse
-
#city ⇒ Object
readonly
Self-explanatory.
-
#country_long_name ⇒ Object
readonly
Self-explanatory.
-
#country_short_name ⇒ Object
readonly
Self-explanatory.
-
#county ⇒ Object
readonly
Self-explanatory.
-
#formatted_address ⇒ Object
readonly
Returns the complete formatted address with standardized abbreviations.
-
#formatted_street_address ⇒ Object
readonly
Returns the formatted street address with standardized abbreviations.
-
#lat ⇒ Object
readonly
Self-explanatory.
-
#lng ⇒ Object
readonly
Self-explanatory.
-
#postal_code ⇒ Object
readonly
Self-explanatory.
-
#state_long_name ⇒ Object
readonly
Self-explanatory.
-
#state_short_name ⇒ Object
readonly
Self-explanatory.
Instance Method Summary collapse
-
#exact_match? ⇒ Boolean
Returns true if the address Google returns is an exact match.
-
#initialize(google_result) ⇒ GeocoderGoogleResult
constructor
Returns a GeocoderGoogleResult initialized with the specified Google geocoding results.
-
#partial_match? ⇒ Boolean
Returns true if the address Google returns isn’t an exact match.
Constructor Details
#initialize(google_result) ⇒ GeocoderGoogleResult
Returns a GeocoderGoogleResult initialized with the specified Google geocoding results.
Attributes
-
google_result
- a hash of Google geocoding results
Examples
white_house = GoogleMapsGeocoder.new '1600 Pennsylvania Washington'
white_house.formatted_address
=> "1600 Pennsylvania Ave NW, Washington D.C., DC 20500, USA"
27 28 29 30 |
# File 'app/models/geocoder_google_result.rb', line 27 def initialize google_result @json = google_result @city, @country_short_name, @country_long_name, @county, @formatted_address, @formatted_street_address, @lat, @lng, @postal_code, @state_long_name, @state_short_name = parse_city, parse_country_short_name, parse_country_long_name, parse_county, parse_formatted_address, parse_formatted_street_address, parse_lat, parse_lng, parse_postal_code, parse_state_long_name, parse_state_short_name end |
Instance Attribute Details
#city ⇒ Object (readonly)
Self-explanatory
12 13 14 |
# File 'app/models/geocoder_google_result.rb', line 12 def city @city end |
#country_long_name ⇒ Object (readonly)
Self-explanatory
12 13 14 |
# File 'app/models/geocoder_google_result.rb', line 12 def country_long_name @country_long_name end |
#country_short_name ⇒ Object (readonly)
Self-explanatory
12 13 14 |
# File 'app/models/geocoder_google_result.rb', line 12 def country_short_name @country_short_name end |
#county ⇒ Object (readonly)
Self-explanatory
12 13 14 |
# File 'app/models/geocoder_google_result.rb', line 12 def county @county end |
#formatted_address ⇒ Object (readonly)
Returns the complete formatted address with standardized abbreviations.
8 9 10 |
# File 'app/models/geocoder_google_result.rb', line 8 def formatted_address @formatted_address end |
#formatted_street_address ⇒ Object (readonly)
Returns the formatted street address with standardized abbreviations.
10 11 12 |
# File 'app/models/geocoder_google_result.rb', line 10 def formatted_street_address @formatted_street_address end |
#lat ⇒ Object (readonly)
Self-explanatory
12 13 14 |
# File 'app/models/geocoder_google_result.rb', line 12 def lat @lat end |
#lng ⇒ Object (readonly)
Self-explanatory
12 13 14 |
# File 'app/models/geocoder_google_result.rb', line 12 def lng @lng end |
#postal_code ⇒ Object (readonly)
Self-explanatory
12 13 14 |
# File 'app/models/geocoder_google_result.rb', line 12 def postal_code @postal_code end |
#state_long_name ⇒ Object (readonly)
Self-explanatory
12 13 14 |
# File 'app/models/geocoder_google_result.rb', line 12 def state_long_name @state_long_name end |
#state_short_name ⇒ Object (readonly)
Self-explanatory
12 13 14 |
# File 'app/models/geocoder_google_result.rb', line 12 def state_short_name @state_short_name end |
Instance Method Details
#exact_match? ⇒ Boolean
Returns true if the address Google returns is an exact match.
Examples
white_house = GoogleMapsGeocoder.new('1600 Pennsylvania Ave')
white_house.exact_match?
=> true
41 42 43 |
# File 'app/models/geocoder_google_result.rb', line 41 def exact_match? ! self.partial_match? end |
#partial_match? ⇒ Boolean
Returns true if the address Google returns isn’t an exact match.
Examples
white_house = GoogleMapsGeocoder.new('1600 Pennsylvania Washington')
white_house.exact_match?
=> false
52 53 54 |
# File 'app/models/geocoder_google_result.rb', line 52 def partial_match? @json['partial_match'] == true end |