class CSVStepImporter::Chunk
Attributes
cache[RW]
first_row[RW]
rows[RW]
Public Class Methods
new(rows: [], row_class: CSVStepImporter::Row, processor_classes: nil, first_row: 0, **attributes)
click to toggle source
Calls superclass method
CSVStepImporter::Node::new
# File lib/csv_step_importer/chunk.rb, line 9 def initialize(rows: [], row_class: CSVStepImporter::Row, processor_classes: nil, first_row: 0, **attributes) super **attributes self.cache = {} self.first_row = first_row add_rows rows: rows, row_class: row_class add_children processor_classes end
Public Instance Methods
add_rows(rows:, row_class:)
click to toggle source
# File lib/csv_step_importer/chunk.rb, line 19 def add_rows(rows:, row_class:) row_parent_node = CSVStepImporter::Node.new parent: self unless rows.empty? || rows.first.is_a?(row_class) row_number = self.first_row - 1 rows = rows.collect do |row| row_class.new(parent: row_parent_node, row_number: row_number += 1, **row) end.find_all(&:include_row?) end @rows = rows row_parent_node.add_children rows add_children row_parent_node end