class PSGC::Import::ImportMunicipalityBarangays::Parser
Attributes
barangays[R]
Public Class Methods
new()
click to toggle source
# File lib/psgc/import/import_municipality_barangays.rb, line 43 def initialize @barangays = [] end
Public Instance Methods
parse(html)
click to toggle source
# File lib/psgc/import/import_municipality_barangays.rb, line 47 def parse(html) html.css('table').each do |table| rows = table/:tr if rows.count == 1 parse_row(rows[0]) if rows.count == 1 end end end
parse_row(tr)
click to toggle source
# File lib/psgc/import/import_municipality_barangays.rb, line 56 def parse_row(tr) tds = tr/:td if tds.size == 4 name = tds[0].text code = tds[1].text urban_rural = tds[2].text.strip population = tds[3].text.gsub(',', '') barangays << [code, name, urban_rural, population] end end