class Geocoder::Result::Mapbox

Public Instance Methods

address() click to toggle source
# File lib/geocoder/results/mapbox.rb, line 42
def address
  [place_name, street, city, state, postal_code, country].compact.join(', ')
end
city() click to toggle source
# File lib/geocoder/results/mapbox.rb, line 18
def city
  context_part('place')
end
coordinates() click to toggle source
# File lib/geocoder/results/mapbox.rb, line 6
def coordinates
  data['geometry']['coordinates'].reverse.map(&:to_f)
end
country() click to toggle source
# File lib/geocoder/results/mapbox.rb, line 32
def country
  context_part('country')
end
Also aliased as: country_code
country_code()
Alias for: country
neighborhood() click to toggle source
# File lib/geocoder/results/mapbox.rb, line 38
def neighborhood
  context_part('neighborhood')
end
place_name() click to toggle source
# File lib/geocoder/results/mapbox.rb, line 10
def place_name
  data['text']
end
postal_code() click to toggle source
# File lib/geocoder/results/mapbox.rb, line 28
def postal_code
  context_part('postcode')
end
state() click to toggle source
# File lib/geocoder/results/mapbox.rb, line 22
def state
  context_part('region')
end
Also aliased as: state_code
state_code()
Alias for: state
street() click to toggle source
# File lib/geocoder/results/mapbox.rb, line 14
def street
  data['properties']['address']
end

Private Instance Methods

context() click to toggle source
# File lib/geocoder/results/mapbox.rb, line 52
def context
  Array(data['context'])
end
context_part(name) click to toggle source
# File lib/geocoder/results/mapbox.rb, line 48
def context_part(name)
  context.map { |c| c['text'] if c['id'] =~ Regexp.new(name) }.compact.first
end