Class: CetSp::Parser
- Inherits:
-
Object
- Object
- CetSp::Parser
- Defined in:
- lib/cetsp.rb
Instance Method Summary collapse
-
#initialize(source) ⇒ Parser
constructor
A new instance of Parser.
- #parse ⇒ Object
Constructor Details
#initialize(source) ⇒ Parser
Returns a new instance of Parser.
9 10 11 12 13 |
# File 'lib/cetsp.rb', line 9 def initialize(source) puts source @parser = Nokogiri::HTML(open(source), nil, 'ASCII-8BIT') @events = [] end |
Instance Method Details
#parse ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/cetsp.rb', line 15 def parse rows = @parser.search('tr.cor1', 'tr.cor2') rows.each do |row| @events << Event.new(:code => row.children[0].to_str.force_encoding("ASCII-8BIT").gsub(/\302\240/, ' ').strip.to_i, :place => row.children[2].to_str.force_encoding("ASCII-8BIT").gsub(/\302\240/, ' ').strip, :direction => row.children[4].to_str.force_encoding("ASCII-8BIT").gsub(/\302\240/, ' ').strip) end @events end |