Class: HarerunParser::Parser
- Inherits:
-
Object
- Object
- HarerunParser::Parser
- Defined in:
- lib/harerun_parser/parser.rb
Constant Summary collapse
- ENCODING =
"Shift_JIS:UTF-8"
Instance Attribute Summary collapse
-
#data_lines ⇒ Object
readonly
Returns the value of attribute data_lines.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#places ⇒ Object
readonly
Returns the value of attribute places.
Instance Method Summary collapse
-
#initialize(io) ⇒ Parser
constructor
A new instance of Parser.
- #normalize ⇒ Object
- #uniq_headers ⇒ Object
Constructor Details
Instance Attribute Details
#data_lines ⇒ Object (readonly)
Returns the value of attribute data_lines.
7 8 9 |
# File 'lib/harerun_parser/parser.rb', line 7 def data_lines @data_lines end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
7 8 9 |
# File 'lib/harerun_parser/parser.rb', line 7 def headers @headers end |
#places ⇒ Object (readonly)
Returns the value of attribute places.
7 8 9 |
# File 'lib/harerun_parser/parser.rb', line 7 def places @places end |
Instance Method Details
#normalize ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/harerun_parser/parser.rb', line 14 def normalize @data_lines.each do |l| day = l.shift @places_line[1, @places_line.size - 1].zip(@headers, l).each do |place, header, value| yield(day, place, header, value) unless value.nil? end end end |
#uniq_headers ⇒ Object
23 24 25 |
# File 'lib/harerun_parser/parser.rb', line 23 def uniq_headers headers.uniq end |