class PSGC::Import::ImportRegions

Import Region List

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/psgc/import/import_regions.rb, line 11
def initialize
  super 'listreg.asp'
end

Public Instance Methods

parse() click to toggle source
# File lib/psgc/import/import_regions.rb, line 15
def parse
  parser = Parser.new
  File.open(full_target) do |input|
    parser.parse Nokogiri::HTML(input)
  end
  header = %w(id name)
  CSV.open(PSGC::Region::REGION_DATA, 'w') do |out|
    out << header
    parser.regions.each {|region| out << region }
  end
  parser.hrefs.each do |id, href|
    irp = ImportRegionProvinces.new id, href
    irp.fetch
  end
end