Class: FlexStationData::ParsePlateReadings
- Inherits:
-
Object
- Object
- FlexStationData::ParsePlateReadings
- Includes:
- Callable
- Defined in:
- lib/flex_station_data/services/parse_plate_readings.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
- #headers ⇒ Object
-
#initialize(plate_data) ⇒ ParsePlateReadings
constructor
A new instance of ParsePlateReadings.
- #readings_block ⇒ Object
- #temperatures ⇒ Object
- #times ⇒ Object
- #wells ⇒ Object
Constructor Details
#initialize(plate_data) ⇒ ParsePlateReadings
Returns a new instance of ParsePlateReadings.
15 16 17 |
# File 'lib/flex_station_data/services/parse_plate_readings.rb', line 15 def initialize(plate_data) @plate_data = plate_data end |
Class Method Details
.parse_row(row) ⇒ Object
61 62 63 64 |
# File 'lib/flex_station_data/services/parse_plate_readings.rb', line 61 def parse_row(row) time, temperature, *values = row [ parse_time(time), parse_value(temperature), *values.map(&method(:parse_value)) ] end |
.parse_time(t) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/flex_station_data/services/parse_plate_readings.rb', line 48 def parse_time(t) return if t.blank? h, m, s = t.split(":").map(&:to_i) h * 60.0 + m + s / 60.0 end |
.parse_value(v) ⇒ Object
55 56 57 58 59 |
# File 'lib/flex_station_data/services/parse_plate_readings.rb', line 55 def parse_value(v) Float(v) rescue ArgumentError, TypeError v.presence end |
Instance Method Details
#call ⇒ Object
43 44 45 |
# File 'lib/flex_station_data/services/parse_plate_readings.rb', line 43 def call [ times, temperatures, wells ] end |
#headers ⇒ Object
27 28 29 |
# File 'lib/flex_station_data/services/parse_plate_readings.rb', line 27 def headers @headers ||= plate_data.detect(&method(:header_row?)).reverse.drop_while(&:blank?).reverse end |
#readings_block ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/flex_station_data/services/parse_plate_readings.rb', line 19 def readings_block @readings_block ||= plate_data .drop_while { |row| !header_row?(row) } .drop_while { |row| !sample_row?(row) } .take_while { |row| !end_row?(row) } .select { |row| row.any?(&:present?) } end |
#temperatures ⇒ Object
35 36 37 |
# File 'lib/flex_station_data/services/parse_plate_readings.rb', line 35 def temperatures @temperatures ||= matrix.column(1).to_a.compact end |
#times ⇒ Object
31 32 33 |
# File 'lib/flex_station_data/services/parse_plate_readings.rb', line 31 def times @times ||= matrix.column(0).to_a.compact end |