Class: Bulkrax::CsvEntry::CsvWrapper
- Inherits:
-
Object
- Object
- Bulkrax::CsvEntry::CsvWrapper
- Includes:
- Enumerable
- Defined in:
- app/models/bulkrax/csv_entry.rb
Overview
The purpose of this class is to reject empty lines. This causes lots of grief in importing. But why not use CSV.read‘s `skip_lines` option? Because for some CSVs, it will never finish reading the file.
There is a spec that demonstrates this approach works.
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(original) ⇒ CsvWrapper
constructor
A new instance of CsvWrapper.
Constructor Details
#initialize(original) ⇒ CsvWrapper
Returns a new instance of CsvWrapper.
37 38 39 |
# File 'app/models/bulkrax/csv_entry.rb', line 37 def initialize(original) @original = original end |
Instance Method Details
#each ⇒ Object
43 44 45 46 47 48 |
# File 'app/models/bulkrax/csv_entry.rb', line 43 def each @original.each do |row| next if all_fields_are_empty_for(row: row) yield(row) end end |