Class: Grobi::Placemark
- Inherits:
-
Object
- Object
- Grobi::Placemark
- Defined in:
- lib/grobi/maps.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#city ⇒ Object
Returns the value of attribute city.
-
#country ⇒ Object
Returns the value of attribute country.
-
#establishment ⇒ Object
Returns the value of attribute establishment.
-
#formatted_address ⇒ Object
Returns the value of attribute formatted_address.
-
#latitude ⇒ Object
Returns the value of attribute latitude.
-
#locality ⇒ Object
Returns the value of attribute locality.
-
#longitude ⇒ Object
Returns the value of attribute longitude.
-
#number ⇒ Object
Returns the value of attribute number.
-
#postal_code ⇒ Object
Returns the value of attribute postal_code.
-
#route ⇒ Object
Returns the value of attribute route.
Instance Method Summary collapse
-
#initialize(json) ⇒ Placemark
constructor
A new instance of Placemark.
- #update(json) ⇒ Object
Constructor Details
#initialize(json) ⇒ Placemark
Returns a new instance of Placemark.
40 41 42 43 44 |
# File 'lib/grobi/maps.rb', line 40 def initialize(json) super() update(json) self end |
Instance Attribute Details
#city ⇒ Object
Returns the value of attribute city.
38 39 40 |
# File 'lib/grobi/maps.rb', line 38 def city @city end |
#country ⇒ Object
Returns the value of attribute country.
38 39 40 |
# File 'lib/grobi/maps.rb', line 38 def country @country end |
#establishment ⇒ Object
Returns the value of attribute establishment.
38 39 40 |
# File 'lib/grobi/maps.rb', line 38 def establishment @establishment end |
#formatted_address ⇒ Object
Returns the value of attribute formatted_address.
38 39 40 |
# File 'lib/grobi/maps.rb', line 38 def formatted_address @formatted_address end |
#latitude ⇒ Object
Returns the value of attribute latitude.
38 39 40 |
# File 'lib/grobi/maps.rb', line 38 def latitude @latitude end |
#locality ⇒ Object
Returns the value of attribute locality.
38 39 40 |
# File 'lib/grobi/maps.rb', line 38 def locality @locality end |
#longitude ⇒ Object
Returns the value of attribute longitude.
38 39 40 |
# File 'lib/grobi/maps.rb', line 38 def longitude @longitude end |
#number ⇒ Object
Returns the value of attribute number.
38 39 40 |
# File 'lib/grobi/maps.rb', line 38 def number @number end |
#postal_code ⇒ Object
Returns the value of attribute postal_code.
38 39 40 |
# File 'lib/grobi/maps.rb', line 38 def postal_code @postal_code end |
#route ⇒ Object
Returns the value of attribute route.
38 39 40 |
# File 'lib/grobi/maps.rb', line 38 def route @route end |
Instance Method Details
#update(json) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/grobi/maps.rb', line 46 def update(json) @formatted_address = json['formatted_address'] if json['geometry'] @longitude = json['geometry']['location']['lng'] @latitude = json['geometry']['location']['lat'] end if json['address_components'] components = json['address_components'].each do |component| @establishment = component['long_name'] if component['types'].include?('establishment') @country = component['short_name'] if component['types'].include?('country') @city = component['long_name'] if component['types'].include?('administrative_area_level_2') @locality = component['long_name'] if component['types'].include?('locality') @route = component['long_name'] if component['types'].include?('route') @number = component['long_name'] if component['types'].include?('street_number') @postal_code = component['long_name'] if component['types'].include?('postal_code') end end end |