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.
-
#initialize(**csv_options) ⇒ CsvCollectionBuilder
constructor
private
A new instance of CsvCollectionBuilder.
-
#no_collection? ⇒ Boolean
private
Returns that the Task processes a collection.
Constructor Details
#initialize(**csv_options) ⇒ CsvCollectionBuilder
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 a new instance of CsvCollectionBuilder.
11 12 13 |
# File 'app/models/maintenance_tasks/csv_collection_builder.rb', line 11 def initialize(**) @csv_options = end |
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.
18 19 20 |
# File 'app/models/maintenance_tasks/csv_collection_builder.rb', line 18 def collection(task) CSV.new(task.csv_content, **@csv_options) 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. It uses the CSV library for an accurate row count. Note that the entire file is loaded. It will take several seconds with files with millions of rows.
27 28 29 |
# File 'app/models/maintenance_tasks/csv_collection_builder.rb', line 27 def count(task) CSV.new(task.csv_content, **@csv_options).count 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.
32 33 34 |
# File 'app/models/maintenance_tasks/csv_collection_builder.rb', line 32 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.
37 38 39 |
# File 'app/models/maintenance_tasks/csv_collection_builder.rb', line 37 def no_collection? false end |