Class: Decidim::TermCustomizer::Import::Readers::Base
- Inherits:
-
Object
- Object
- Decidim::TermCustomizer::Import::Readers::Base
- Defined in:
- lib/decidim/term_customizer/import/readers/base.rb
Overview
Imports an exported file to data arrays that can be processed during yields.
Instance Method Summary collapse
-
#initialize(file) ⇒ Base
constructor
A new instance of Base.
-
#read_rows ⇒ Object
The read_rows method should iterate over each row of the data and yield the data array of each row with the row’s index.
Constructor Details
#initialize(file) ⇒ Base
Returns a new instance of Base.
10 11 12 |
# File 'lib/decidim/term_customizer/import/readers/base.rb', line 10 def initialize(file) @file = file end |
Instance Method Details
#read_rows ⇒ Object
The read_rows method should iterate over each row of the data and yield the data array of each row with the row’s index. For example, this could look like following:
Parser.read(file).rows.each_with_index do |row, index|
yield row.to_a, index
end
The first row yielded with index 0 needs to contain the data headers which can be later used to map the data to correct attributes.
This needs to be implemented by the extending classes.
25 26 27 |
# File 'lib/decidim/term_customizer/import/readers/base.rb', line 25 def read_rows raise NotImplementedError end |