Class: SampleManifestExcel::Upload::Rows

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model, Enumerable
Defined in:
app/sample_manifest_excel/sample_manifest_excel/upload/rows.rb

Overview

A collection of Rows which relates to the data section of an uploaded spreadsheet Rows are valid if all of the rows are valid Expects an Upload::Data object.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, columns, cache = SampleManifestAsset) ⇒ Rows

Returns a new instance of Rows.



20
21
22
23
24
# File 'app/sample_manifest_excel/sample_manifest_excel/upload/rows.rb', line 20

def initialize(data, columns, cache = SampleManifestAsset)
  @data = data || []
  @columns = columns
  @items = create_rows(cache)
end

Instance Attribute Details

#columnsObject (readonly)

Returns the value of attribute columns.



13
14
15
# File 'app/sample_manifest_excel/sample_manifest_excel/upload/rows.rb', line 13

def columns
  @columns
end

#dataObject (readonly)

Returns the value of attribute data.



13
14
15
# File 'app/sample_manifest_excel/sample_manifest_excel/upload/rows.rb', line 13

def data
  @data
end

#itemsObject (readonly)

Returns the value of attribute items.



13
14
15
# File 'app/sample_manifest_excel/sample_manifest_excel/upload/rows.rb', line 13

def items
  @items
end

#plate_metadataObject (readonly)

Returns the value of attribute plate_metadata.



13
14
15
# File 'app/sample_manifest_excel/sample_manifest_excel/upload/rows.rb', line 13

def 
  @plate_metadata
end

Instance Method Details

#data_at(row_num) ⇒ Object

Return values for rows for a particular column number there is a similar method data#column(n), but it returns column of data for all rows (including empty ones)



32
33
34
# File 'app/sample_manifest_excel/sample_manifest_excel/upload/rows.rb', line 32

def data_at(row_num)
  map { |row| row.at(row_num) }
end

#eachObject



26
27
28
# File 'app/sample_manifest_excel/sample_manifest_excel/upload/rows.rb', line 26

def each(&)
  items.each(&)
end