Class: SimpleEtl::Source::FixedWidth::Parser
- Defined in:
- lib/simple_etl/source/fixed_width/parser.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #fetch_field_from_row(row, field) ⇒ Object
-
#initialize(&block) ⇒ Parser
constructor
A new instance of Parser.
- #read_rows(src, args) ⇒ Object
Methods inherited from Base
#generate_field, #parse, #parse_field, #parse_row
Constructor Details
Instance Method Details
#fetch_field_from_row(row, field) ⇒ Object
9 10 11 12 13 |
# File 'lib/simple_etl/source/fixed_width/parser.rb', line 9 def fetch_field_from_row row, field length = field[:length] length = row.length - field[:start] if length == :eol row[field[:start], length] end |
#read_rows(src, args) ⇒ Object
15 16 17 |
# File 'lib/simple_etl/source/fixed_width/parser.rb', line 15 def read_rows src, args (args[:type] == :inline && src.lines || File.readlines(src)).map &:chomp end |