Class: AsciiDataTools::Filter::ParsingFilter

Inherits:
Filter
  • Object
show all
Defined in:
lib/ascii-data-tools/filter.rb

Instance Method Summary collapse

Methods inherited from Filter

#<<, #has_records?, #read, #write

Constructor Details

#initialize(record_types) ⇒ ParsingFilter

Returns a new instance of ParsingFilter.



110
111
112
# File 'lib/ascii-data-tools/filter.rb', line 110

def initialize(record_types)
  @record_types = record_types
end

Instance Method Details

#filter(record) ⇒ Object



114
115
116
117
118
119
120
121
122
# File 'lib/ascii-data-tools/filter.rb', line 114

def filter(record)
  header_line = record
  record_type = identify_record_type_from(header_line)
  values = parse_values_from_subsequent_lines(record_type)
  
  consume_empty_line_between_records
  
  AsciiDataTools::Record::Record.new(record_type, values)
end