class FiasReader::Cache::AddressPart::LevelAdapter

Attributes

item[R]

Public Class Methods

new(item) click to toggle source
# File lib/fias_reader/cache/address_part/level_adapter.rb, line 19
def initialize(item)
  @item = item
end

Public Instance Methods

autonomy() click to toggle source

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

# File lib/fias_reader/cache/address_part/level_adapter.rb, line 126
def autonomy
  [@item.shortname_l2, @item.offname_l2]
end
city() click to toggle source

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

# File lib/fias_reader/cache/address_part/level_adapter.rb, line 116
def city
  [@item.shortname_l4, @item.offname_l4]
end
city_district() click to toggle source

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

# File lib/fias_reader/cache/address_part/level_adapter.rb, line 111
def city_district
  [@item.shortname_l5, @item.offname_l5]
end
copy(other) click to toggle source
# 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
district() click to toggle source

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

# File lib/fias_reader/cache/address_part/level_adapter.rb, line 121
def district
  [@item.shortname_l3, @item.offname_l3]
end
reset_own() click to toggle source
# 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
settlement() click to toggle source

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

# File lib/fias_reader/cache/address_part/level_adapter.rb, line 106
def settlement
  [@item.shortname_l6, @item.offname_l6]
end
state() click to toggle source

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

# File lib/fias_reader/cache/address_part/level_adapter.rb, line 131
def state
  [@item.shortname_l1, @item.offname_l1]
end
street() click to toggle source

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

# File lib/fias_reader/cache/address_part/level_adapter.rb, line 101
def street
  [@item.shortname_l7, @item.offname_l7]
end