Class: FlexStationData::ParseSampleMap

Inherits:
Object
  • Object
show all
Includes:
Callable
Defined in:
lib/flex_station_data/services/parse_sample_map.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(plate_data) ⇒ ParseSampleMap

Returns a new instance of ParseSampleMap.



14
15
16
# File 'lib/flex_station_data/services/parse_sample_map.rb', line 14

def initialize(plate_data)
  @plate_data = plate_data
end

Instance Attribute Details

#plate_dataObject (readonly)

Returns the value of attribute plate_data.



12
13
14
# File 'lib/flex_station_data/services/parse_sample_map.rb', line 12

def plate_data
  @plate_data
end

Instance Method Details

#callObject



26
27
28
29
30
31
# File 'lib/flex_station_data/services/parse_sample_map.rb', line 26

def call
  sample_map_rows.each_with_object([]) do |(label, well), memo|
    memo << [ label, [] ] if label.present?
    memo.last.last << well
  end.to_h
end

#sample_map_rowsObject



18
19
20
21
22
23
24
# File 'lib/flex_station_data/services/parse_sample_map.rb', line 18

def sample_map_rows
  plate_data
    .drop_while { |row| !sample_map_header?(row) }
    .drop(1)
    .take_while { |row| !empty_row?(row) }
    .map(&method(:parse_row))
end