Class: FixedWidth::Parser
- Inherits:
-
Object
- Object
- FixedWidth::Parser
- Defined in:
- lib/fixed_width/parser.rb
Instance Method Summary collapse
-
#initialize(definition, file) ⇒ Parser
constructor
A new instance of Parser.
- #parse ⇒ Object
Constructor Details
#initialize(definition, file) ⇒ Parser
Returns a new instance of Parser.
3 4 5 6 |
# File 'lib/fixed_width/parser.rb', line 3 def initialize(definition, file) @definition = definition @file = file end |
Instance Method Details
#parse ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/fixed_width/parser.rb', line 8 def parse @parsed = {} @content = read_file unless @content.empty? @definition.sections.each do |section| rows = fill_content(section) raise FixedWidth::RequiredSectionNotFoundError.new("Required section '#{section.name}' was not found.") unless rows > 0 || section.optional end end @parsed end |