class PSGC::Import::ImportRegionProvinces::Parser
Attributes
hrefs[R]
provinces[R]
Public Class Methods
new()
click to toggle source
# File lib/psgc/import/import_region_provinces.rb, line 40 def initialize @provinces = [] @hrefs = {} end
Public Instance Methods
parse(html)
click to toggle source
# File lib/psgc/import/import_region_provinces.rb, line 45 def parse(html) html.css('table').each do |table| rows = table/:tr parse_row(rows[0]) if rows.count == 1 end end
parse_row(tr)
click to toggle source
# File lib/psgc/import/import_region_provinces.rb, line 52 def parse_row(tr) tds = tr/:td if tds.size == 6 a = tds[0].css('p a') if a name = a.text href = a[0]['href'] id = tds[1].text[0, 4] @provinces << [id, name] @hrefs[id] = "province.asp?provCode=#{id}00000" end end end