Method: DistrictHelper.scan_area

Defined in:
lib/china_district_code/helpers/district_helper.rb

.scan_area(html) ⇒ Object

find the area and formatting



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/china_district_code/helpers/district_helper.rb', line 51

def self.scan_area(html)
  areas = html.scan /\d{6}        [\u4e00-\u9fa5]+/
  result = []
  areas.each do |e|
    tmp = e.split(/        /)
    name = tmp[1]
    next if name.eql?('市辖区')
    code = tmp[0]
    pro_prefix = code[0,2]
    city_prefix = code[2,2]
    area_prefix = code[4,2]
    result.push [pro_prefix,city_prefix,area_prefix,code,name]
  end
  result
end