Class: MaintenanceTasks::CsvCollectionBuilder Private
- Inherits:
-
Object
- Object
- MaintenanceTasks::CsvCollectionBuilder
- Defined in:
- app/models/maintenance_tasks/csv_collection_builder.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Strategy for building a Task that processes CSV files.
Direct Known Subclasses
Instance Method Summary collapse
-
#collection(task) ⇒ CSV
private
Defines the collection to be iterated over, based on the provided CSV.
-
#count(task) ⇒ Integer
private
The number of rows to be processed.
-
#has_csv_content? ⇒ Boolean
private
Return that the Task processes CSV content.
-
#no_collection? ⇒ Boolean
private
Returns that the Task processes a collection.
Instance Method Details
#collection(task) ⇒ CSV
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Defines the collection to be iterated over, based on the provided CSV.
14 15 16 |
# File 'app/models/maintenance_tasks/csv_collection_builder.rb', line 14 def collection(task) CSV.new(task.csv_content, headers: true) end |
#count(task) ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The number of rows to be processed. Excludes the header row from the count and assumes a trailing newline is at the end of the CSV file. Note that this number is an approximation based on the number of newlines.
24 25 26 |
# File 'app/models/maintenance_tasks/csv_collection_builder.rb', line 24 def count(task) task.csv_content.count("\n") - 1 end |
#has_csv_content? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return that the Task processes CSV content.
29 30 31 |
# File 'app/models/maintenance_tasks/csv_collection_builder.rb', line 29 def has_csv_content? true end |
#no_collection? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns that the Task processes a collection.
34 35 36 |
# File 'app/models/maintenance_tasks/csv_collection_builder.rb', line 34 def no_collection? false end |