class PSGC::Import::ImportRegions::Parser

Attributes

hrefs[R]
regions[R]

Public Class Methods

new() click to toggle source
# File lib/psgc/import/import_regions.rb, line 35
def initialize
  @regions = []
  @hrefs = {}
end

Public Instance Methods

parse(html) click to toggle source
# File lib/psgc/import/import_regions.rb, line 40
def parse(html)
  html.css('table.table4').each do |table|
    parse_table(table)
  end
end
parse_table(table) click to toggle source
# File lib/psgc/import/import_regions.rb, line 46
def parse_table(table)
  td = table/:td
  if (td.size == 2)
    p = td[0]/:p
    href = (p/:a)[0]['href']
    id = href[/=(\d+)$/, 1]
    name = (p/:strong).text
    @regions << [id, name]
    @hrefs[id] = href
  end
end