Class: PSGC::Import::ImportRegions
- Defined in:
- lib/psgc/import/import_regions.rb
Overview
Import Region List
Defined Under Namespace
Classes: Parser
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize ⇒ ImportRegions
constructor
A new instance of ImportRegions.
- #parse ⇒ Object
Methods inherited from Base
Constructor Details
#initialize ⇒ ImportRegions
Returns a new instance of ImportRegions.
11 12 13 |
# File 'lib/psgc/import/import_regions.rb', line 11 def initialize super 'listreg.asp' end |
Instance Method Details
#parse ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# 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 |