Class: MaintenanceTasks::CsvCollectionBuilder Private

Inherits:
Object
  • Object
show all
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

BatchCsvCollectionBuilder

Instance Method Summary collapse

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.

Returns:

  • (CSV)

    the CSV object constructed from the specified CSV content, with headers.



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.

Returns:

  • (Integer)

    the approximate number of rows to process.



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.

Returns:

  • (Boolean)


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.

Returns:

  • (Boolean)


34
35
36
# File 'app/models/maintenance_tasks/csv_collection_builder.rb', line 34

def no_collection?
  false
end