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
|
require 'geocoder/results/base'
module Geocoder::Result
class PostcodeAnywhereUk < Base
def coordinates
[@data['Latitude'].to_f, @data['Longitude'].to_f]
end
def blank_result
''
end
alias_method :state, :blank_result
alias_method :state_code, :blank_result
alias_method :postal_code, :blank_result
def address
@data['Location']
end
def city
# is this too big a jump to assume that the API always
# returns a City, County as the last elements?
city = @data['Location'].split(',')[-2] || blank_result
city.strip
end
def os_grid
@data['OsGrid']
end
# This is a UK only API; all results are UK specific and
# so ommitted from API response.
def country
'United Kingdom'
end
def country_code
'UK'
end
end
end
|