Class: Geocoder::Result::PostcodeAnywhereUk

Inherits:
Base
  • Object
show all
Defined in:
lib/geocoder/results/postcode_anywhere_uk.rb

Instance Attribute Summary

Attributes inherited from Base

#cache_hit, #data

Instance Method Summary collapse

Methods inherited from Base

#initialize, #latitude, #longitude, #province, #province_code

Constructor Details

This class inherits a constructor from Geocoder::Result::Base

Instance Method Details

#addressObject



17
18
19
# File 'lib/geocoder/results/postcode_anywhere_uk.rb', line 17

def address
  @data['Location']
end

#blank_resultObject Also known as: state, state_code, postal_code



10
11
12
# File 'lib/geocoder/results/postcode_anywhere_uk.rb', line 10

def blank_result
  ''
end

#cityObject



21
22
23
24
25
26
# File 'lib/geocoder/results/postcode_anywhere_uk.rb', line 21

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

#coordinatesObject



6
7
8
# File 'lib/geocoder/results/postcode_anywhere_uk.rb', line 6

def coordinates
  [@data['Latitude'].to_f, @data['Longitude'].to_f]
end

#countryObject

This is a UK only API; all results are UK specific and so ommitted from API response.



34
35
36
# File 'lib/geocoder/results/postcode_anywhere_uk.rb', line 34

def country
  'United Kingdom'
end

#country_codeObject



38
39
40
# File 'lib/geocoder/results/postcode_anywhere_uk.rb', line 38

def country_code
  'UK'
end

#os_gridObject



28
29
30
# File 'lib/geocoder/results/postcode_anywhere_uk.rb', line 28

def os_grid
  @data['OsGrid']
end