Module: CsvRowModel::Export::FileModel
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/csv_row_model/export/file_model.rb
Class Method Summary collapse
Instance Method Summary collapse
- #header?(cell) ⇒ Boolean private
-
#rows_template ⇒ Array<Array>
Safe to override.
-
#to_rows ⇒ Array
An array of rows, where if cell is row_name, it's parsed into the header_match and everything else is return as is.
Class Method Details
.setup(csv, context, with_headers: true) ⇒ Object
32 |
# File 'lib/csv_row_model/export/file_model.rb', line 32 def setup(csv, context, with_headers: true); end |
Instance Method Details
#header?(cell) ⇒ Boolean (private)
37 38 39 |
# File 'lib/csv_row_model/export/file_model.rb', line 37 def header?(cell) self.class.is_row_name? cell end |
#rows_template ⇒ Array<Array>
Safe to override
27 28 29 |
# File 'lib/csv_row_model/export/file_model.rb', line 27 def rows_template @rows_template ||= self.class.row_names.map { |row_name| [row_name] } end |
#to_rows ⇒ Array
Returns an array of rows, where if cell is row_name, it's parsed into the header_match and everything else is return as is.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/csv_row_model/export/file_model.rb', line 8 def to_rows rows_template.map do |row| [].tap do |result| row.each do |cell| if header? cell result << self.class.format_header(cell, context) else result << cell.to_s end end end end end |