Class: Graticule::Geocoder::Mapbox::Result
- Inherits:
-
Object
- Object
- Graticule::Geocoder::Mapbox::Result
- Defined in:
- lib/graticule/geocoder/mapbox.rb
Overview
A result looks like: [
{
"id"=>"address.110173544177",
"lon"=>-122.02912,
"lat"=>37.33054,
"name"=>"1 Infinite Loop",
"type"=>"address"
}, {
"id"=>"mapbox-places.95014",
"name"=>"Cupertino",
"type"=>"city"
}, {
"id"=>"province.1112151813",
"name"=>"California",
"type"=>"province"
}, {
"id"=>"country.4150104525",
"name"=>"United States",
"type"=>"country"
}
]
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#city ⇒ Object
Returns the value of attribute city.
-
#country ⇒ Object
Returns the value of attribute country.
-
#lat ⇒ Object
Returns the value of attribute lat.
-
#lon ⇒ Object
Returns the value of attribute lon.
-
#postal_code ⇒ Object
Returns the value of attribute postal_code.
-
#precision ⇒ Object
Returns the value of attribute precision.
-
#province ⇒ Object
Returns the value of attribute province.
Instance Method Summary collapse
-
#initialize(input) ⇒ Result
constructor
A new instance of Result.
Constructor Details
#initialize(input) ⇒ Result
Returns a new instance of Result.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/graticule/geocoder/mapbox.rb', line 41 def initialize(input) self.precision = ::Graticule::Precision::Unknown self.lat = input.first["lat"] self.lon = input.first["lon"] input.each do |tuple| case tuple["type"] when "zipcode" self.postal_code = tuple["name"] set_higher_precision(::Graticule::Precision::PostalCode) when "address" self.address = tuple["name"] set_higher_precision(::Graticule::Precision::Address) when "city" self.city = tuple["name"] set_higher_precision(::Graticule::Precision::Locality) self.postal_code = tuple["id"].split(".")[1] when "province" self.province = tuple["name"] set_higher_precision(::Graticule::Precision::Region) when "country" self.country = tuple["name"] set_higher_precision(::Graticule::Precision::Country) end end end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
39 40 41 |
# File 'lib/graticule/geocoder/mapbox.rb', line 39 def address @address end |
#city ⇒ Object
Returns the value of attribute city.
39 40 41 |
# File 'lib/graticule/geocoder/mapbox.rb', line 39 def city @city end |
#country ⇒ Object
Returns the value of attribute country.
39 40 41 |
# File 'lib/graticule/geocoder/mapbox.rb', line 39 def country @country end |
#lat ⇒ Object
Returns the value of attribute lat.
39 40 41 |
# File 'lib/graticule/geocoder/mapbox.rb', line 39 def lat @lat end |
#lon ⇒ Object
Returns the value of attribute lon.
39 40 41 |
# File 'lib/graticule/geocoder/mapbox.rb', line 39 def lon @lon end |
#postal_code ⇒ Object
Returns the value of attribute postal_code.
39 40 41 |
# File 'lib/graticule/geocoder/mapbox.rb', line 39 def postal_code @postal_code end |
#precision ⇒ Object
Returns the value of attribute precision.
39 40 41 |
# File 'lib/graticule/geocoder/mapbox.rb', line 39 def precision @precision end |
#province ⇒ Object
Returns the value of attribute province.
39 40 41 |
# File 'lib/graticule/geocoder/mapbox.rb', line 39 def province @province end |