Class: LabwareCreators::CustomPooledTubes::CsvFile::Header

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
app/models/labware_creators/custom_pooled_tubes/csv_file/header.rb

Overview

Class HeaderRow provides a simple wrapper for handling and validating individual CSV rows

Constant Summary collapse

SOURCE_COLUMN =
'Source Well'
DEST_COLUMN =
'Dest. well'
VOL_COLUMN =
'Volume to add to pool'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(row) ⇒ Header

Generates a header from the header row array

Parameters:

  • row (Array)

    The array of fields extracted from the CSV file



29
30
31
32
33
34
# File 'app/models/labware_creators/custom_pooled_tubes/csv_file/header.rb', line 29

def initialize(row)
  @row = row || []
  @source_column = index_of_header(SOURCE_COLUMN)
  @destination_column = index_of_header(DEST_COLUMN)
  @volume_column = index_of_header(VOL_COLUMN)
end

Instance Attribute Details

#destination_columnObject (readonly)

Return the index of the respective column.



14
15
16
# File 'app/models/labware_creators/custom_pooled_tubes/csv_file/header.rb', line 14

def destination_column
  @destination_column
end

#source_columnObject (readonly)

Return the index of the respective column.



14
15
16
# File 'app/models/labware_creators/custom_pooled_tubes/csv_file/header.rb', line 14

def source_column
  @source_column
end

#volume_columnObject (readonly)

Return the index of the respective column.



14
15
16
# File 'app/models/labware_creators/custom_pooled_tubes/csv_file/header.rb', line 14

def volume_column
  @volume_column
end

Instance Method Details

#to_s<String] Outputs the raw header data

Outputs the header as a string

Returns:

  • (<String] Outputs the raw header data)

    <String] Outputs the raw header data



41
42
43
# File 'app/models/labware_creators/custom_pooled_tubes/csv_file/header.rb', line 41

def to_s
  @row.join(',')
end