Class: Geocoder::Result::Twogis

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

Instance Attribute Summary

Attributes inherited from Base

#cache_hit, #data

Instance Method Summary collapse

Methods inherited from Base

#country_code, #initialize, #latitude, #longitude, #province, #province_code, #state, #state_code

Constructor Details

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

Instance Method Details

#address(_format = :full) ⇒ Object


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

def address(_format = :full)
  @data['full_address_name'] || ''
end

#building_nameObject


60
61
62
# File 'lib/geocoder/results/twogis.rb', line 60

def building_name
  @data['building_name'] || ''
end

#cityObject


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

def city
  return '' unless @data['adm_div']
  @data['adm_div'].select{|u| u["type"] == "city"}.first.try(:[], 'name') || ''
end

#coordinatesObject


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

def coordinates
  ['lat', 'lon'].map{ |i| @data['point'][i] } if @data['point']
end

#countryObject


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

def country
  return '' unless @data['adm_div']
  @data['adm_div'].select{|u| u["type"] == "country"}.first.try(:[], 'name') || ''
end

#districtObject


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

def district
  return '' unless @data['adm_div']
  @data['adm_div'].select{|u| u["type"] == "district"}.first.try(:[], 'name') || ''
end

#district_areaObject


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

def district_area
  return '' unless @data['adm_div']
  @data['adm_div'].select{|u| u["type"] == "district_area"}.first.try(:[], 'name') || ''
end

#nameObject


72
73
74
# File 'lib/geocoder/results/twogis.rb', line 72

def name
  @data['name'] || ''
end

#purpose_nameObject


56
57
58
# File 'lib/geocoder/results/twogis.rb', line 56

def purpose_name
  @data['purpose_name'] || ''
end

#regionObject


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

def region
  return '' unless @data['adm_div']
  @data['adm_div'].select{|u| u["type"] == "region"}.first.try(:[], 'name') || ''
end

#streetObject


42
43
44
45
# File 'lib/geocoder/results/twogis.rb', line 42

def street
  return '' unless @data['address_name']
  @data['address_name'].split(', ').first
end

#street_addressObject


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

def street_address
  @data['address_name'] || ''
end

#street_numberObject


47
48
49
50
# File 'lib/geocoder/results/twogis.rb', line 47

def street_number
  return '' unless @data['address_name']
  @data['address_name'].split(', ')[1] || ''
end

#subtypeObject


64
65
66
# File 'lib/geocoder/results/twogis.rb', line 64

def subtype
  @data['subtype'] || ''
end

#subtype_specificationObject


68
69
70
# File 'lib/geocoder/results/twogis.rb', line 68

def subtype_specification
  @data['subtype_specification'] || ''
end

#typeObject


52
53
54
# File 'lib/geocoder/results/twogis.rb', line 52

def type
  @data['type'] || ''
end