Class: FiasReader::Cache::AddressPart::LevelAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/fias_reader/cache/address_part/level_adapter.rb

Defined Under Namespace

Modules: AddressObjectLevel

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(item) ⇒ LevelAdapter

Returns a new instance of LevelAdapter.



19
20
21
# File 'lib/fias_reader/cache/address_part/level_adapter.rb', line 19

def initialize(item)
  @item = item
end

Instance Attribute Details

#itemObject (readonly)

Returns the value of attribute item.



17
18
19
# File 'lib/fias_reader/cache/address_part/level_adapter.rb', line 17

def item
  @item
end

Instance Method Details

#autonomyObject

Возвращает автономный округ



126
127
128
# File 'lib/fias_reader/cache/address_part/level_adapter.rb', line 126

def autonomy
  [@item.shortname_l2, @item.offname_l2]
end

#cityObject

Возвращает город



116
117
118
# File 'lib/fias_reader/cache/address_part/level_adapter.rb', line 116

def city
  [@item.shortname_l4, @item.offname_l4]
end

#city_districtObject

Возвращает внутригородской территории



111
112
113
# File 'lib/fias_reader/cache/address_part/level_adapter.rb', line 111

def city_district
  [@item.shortname_l5, @item.offname_l5]
end

#copy(other) ⇒ Object



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
49
50
51
# File 'lib/fias_reader/cache/address_part/level_adapter.rb', line 23

def copy(other)
  @item.shortname_l1 = other.item.shortname_l1
  @item.offname_l1 = other.item.offname_l1
  @item.shortname_l2 = other.item.shortname_l2
  @item.offname_l2 = other.item.offname_l2
  @item.shortname_l3 = other.item.shortname_l3
  @item.offname_l3 = other.item.offname_l3
  @item.shortname_l4 = other.item.shortname_l4
  @item.offname_l4 = other.item.offname_l4
  @item.shortname_l5 = other.item.shortname_l5
  @item.offname_l5 = other.item.offname_l5
  @item.shortname_l6 = other.item.shortname_l6
  @item.offname_l6 = other.item.offname_l6
  @item.shortname_l7 = other.item.shortname_l7
  @item.offname_l7 = other.item.offname_l7
  @item.shortname_l8 = other.item.shortname_l8
  @item.offname_l8 = other.item.offname_l8
  @item.shortname_l9 = other.item.shortname_l9
  @item.offname_l9 = other.item.offname_l9
  @item.shortname_l65 = other.item.shortname_l65
  @item.offname_l65 = other.item.offname_l65
  @item.shortname_l75 = other.item.shortname_l75
  @item.offname_l75 = other.item.offname_l75
  @item.shortname_l90 = other.item.shortname_l90
  @item.offname_l90 = other.item.offname_l90
  @item.shortname_l91 = other.item.shortname_l91
  @item.offname_l91 = other.item.offname_l91
  reset_own
end

#districtObject

Возвращает район



121
122
123
# File 'lib/fias_reader/cache/address_part/level_adapter.rb', line 121

def district
  [@item.shortname_l3, @item.offname_l3]
end

#reset_ownObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/fias_reader/cache/address_part/level_adapter.rb', line 53

def reset_own
  case @item[:AOLEVEL]
  when 1
    @item.shortname_l1 = @item[:SHORTNAME]
    @item.offname_l1 = @item[:OFFNAME]
  when 2
    @item.shortname_l2 = @item[:SHORTNAME]
    @item.offname_l2 = @item[:OFFNAME]
  when 3
    @item.shortname_l3 = @item[:SHORTNAME]
    @item.offname_l3 = @item[:OFFNAME]
  when 4
    @item.shortname_l4 = @item[:SHORTNAME]
    @item.offname_l4 = @item[:OFFNAME]
  when 5
    @item.shortname_l5 = @item[:SHORTNAME]
    @item.offname_l5 = @item[:OFFNAME]
  when 6
    @item.shortname_l6 = @item[:SHORTNAME]
    @item.offname_l6 = @item[:OFFNAME]
  when 7
    @item.shortname_l7 = @item[:SHORTNAME]
    @item.offname_l7 = @item[:OFFNAME]
  when 8
    @item.shortname_l8 = @item[:SHORTNAME]
    @item.offname_l8 = @item[:OFFNAME]
  when 9
    @item.shortname_l9 = @item[:SHORTNAME]
    @item.offname_l9 = @item[:OFFNAME]
  when 65
    @item.shortname_l65 = @item[:SHORTNAME]
    @item.offname_l65 = @item[:OFFNAME]
  when 75
    @item.shortname_l75 = @item[:SHORTNAME]
    @item.offname_l75 = @item[:OFFNAME]
  when 90
    @item.shortname_l90 = @item[:SHORTNAME]
    @item.offname_l90 = @item[:OFFNAME]
  when 91
    @item.shortname_l91 = @item[:SHORTNAME]
    @item.offname_l91 = @item[:OFFNAME]
  else
    raise 'errors'
  end
  @item.levels_filled = true
end

#settlementObject

Возвращает деревню, поселок



106
107
108
# File 'lib/fias_reader/cache/address_part/level_adapter.rb', line 106

def settlement
  [@item.shortname_l6, @item.offname_l6]
end

#stateObject

Возвращает область



131
132
133
# File 'lib/fias_reader/cache/address_part/level_adapter.rb', line 131

def state
  [@item.shortname_l1, @item.offname_l1]
end

#streetObject

Возвращает улицу



101
102
103
# File 'lib/fias_reader/cache/address_part/level_adapter.rb', line 101

def street
  [@item.shortname_l7, @item.offname_l7]
end