1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
require 'geocoder/results/base'
module Geocoder::Result
class Mapquest < Base
def coordinates
%w[lat lng].map{ |l| @data["latLng"][l] }
end
def city
@data['adminArea5']
end
def street
@data['street']
end
def state
@data['adminArea3']
end
def county
@data['adminArea4']
end
alias_method :state_code, :state
#FIXME: these might not be right, unclear with MQ documentation
alias_method :province, :state
alias_method :province_code, :state
def postal_code
@data['postalCode'].to_s
end
def country
@data['adminArea1']
end
def country_code
country
end
def address
[street, city, state, postal_code, country].reject{|s| s.length == 0 }.join(", ")
end
end
end
|