lib/flex_station_data/wells.rb in flex-station-data-0.3.1 vs lib/flex_station_data/wells.rb in flex-station-data-0.3.2

- old
+ new

@@ -1,29 +1,28 @@ -require "flex_station_data/readings" +require "matrix" module FlexStationData class Wells - def initialize(plate_readings_matrix) - @plate_readings_matrix = plate_readings_matrix + attr_reader :matrix + + def initialize(matrix) + @matrix = matrix end - def readings(well_label) - well_index[well_label] ||= begin - row, column = parse_well_label(well_label) - Readings.new(well_label, plate_readings_matrix[row][column]) - end + def values(well_label) + matrix[*coordinates(well_label)] end - def parse_well_label(well_label) - row, column = well_label.scan(/\A([A-Z])(\d+)\z/).first - [ row.ord - "A".ord, column.to_i - 1 ] + def coordinates(well_label) + coordinates_index[well_label] ||= begin + row, column = well_label.scan(/\A([A-Z])(\d+)\z/).first + [ row.ord - "A".ord, column.to_i - 1 ] + end end private - def well_index - @well_index ||= {} + def coordinates_index + @coordinates_index ||= {} end - - attr_reader :plate_readings_matrix end end