Class: Geocoder::Result::Osmnames

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

Instance Attribute Summary

Attributes inherited from Base

#cache_hit, #data

Class Method Summary collapse

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

Class Method Details

.response_attributesObject



43
44
45
46
# File 'lib/geocoder/results/osmnames.rb', line 43

def self.response_attributes
  %w[house_number street city name osm_id osm_type boundingbox place_rank
  importance county rank name_suffix]
end

Instance Method Details

#addressObject



5
6
7
# File 'lib/geocoder/results/osmnames.rb', line 5

def address
  @data['display_name']
end

#coordinatesObject



9
10
11
# File 'lib/geocoder/results/osmnames.rb', line 9

def coordinates
  [@data['lat'].to_f, @data['lon'].to_f]
end

#countryObject



39
40
41
# File 'lib/geocoder/results/osmnames.rb', line 39

def country
  @data['country']
end

#country_codeObject



35
36
37
# File 'lib/geocoder/results/osmnames.rb', line 35

def country_code
  @data['country_code']
end

#place_classObject



23
24
25
# File 'lib/geocoder/results/osmnames.rb', line 23

def place_class
  @data['class']
end

#place_typeObject



27
28
29
# File 'lib/geocoder/results/osmnames.rb', line 27

def place_type
  @data['type']
end

#postal_codeObject



31
32
33
# File 'lib/geocoder/results/osmnames.rb', line 31

def postal_code
  ''
end

#stateObject Also known as: state_code



18
19
20
# File 'lib/geocoder/results/osmnames.rb', line 18

def state
  @data['state']
end

#viewportObject



13
14
15
16
# File 'lib/geocoder/results/osmnames.rb', line 13

def viewport
  west, south, east, north = @data['boundingbox'].map(&:to_f)
  [south, west, north, east]
end