Class: NdrImport::FixedWidth::Table
- Defined in:
- lib/ndr_import/fixed_width/table.rb
Overview
This class maintains the state of a fixed width table mapping and encapsulates the logic required to transform a table of data into “records”. Particular attention has been made to use enumerables throughout to help with the transformation of large quantities of data.
Instance Attribute Summary
Attributes inherited from Table
Instance Method Summary collapse
-
#transform_line(line, index) ⇒ Object
This method transforms an incoming line of fixed wwidrh data by applying each of the klass masked mappings to the line and yielding the klass and fields for each mapped klass.
Methods inherited from Table
all_valid_options, #all_valid_options, #encode_with, #header_valid?, #initialize, #match, #process_line, #transform
Constructor Details
This class inherits a constructor from NdrImport::Table
Instance Method Details
#transform_line(line, index) ⇒ Object
This method transforms an incoming line of fixed wwidrh data by applying each of the klass masked mappings to the line and yielding the klass and fields for each mapped klass.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ndr_import/fixed_width/table.rb', line 13 def transform_line(line, index) return enum_for(:transform_line, line, index) unless block_given? masked_mappings.each do |klass, klass_mappings| line = fixed_width_columns(line, klass_mappings) fields = mapped_line(line, klass_mappings) next if fields[:skip].to_s == 'true'.freeze yield(klass, fields, index) end end |