#!/usr/bin/env ruby require "flex_station_data/services/load_plates" module FlexStationData class SampleDataApp include Concerns::Service attr_reader :args def initialize(*args) @args = args end def files @files ||= args.map { |arg| Pathname(arg) } end def plates @plates ||= files.map do |file| [ file, LoadPlates.call(file) ] end end def call plates.each do |file, file_plates| puts "File: #{file.to_path}" file_plates.each_with_index.map do |plate, plate_index| puts "Plate: #{plate_index + 1}" plate.samples.each do |sample| readings_labels = sample.readings.map(&:label) puts "Sample #{sample.label}" CSV do |out| mean = sample.mean out << ["time", *sample.readings.map(&:label), mean.label] plate.times.zip(*sample.readings.map(&:values), mean.values).each do |row| out << row end out << [] end end end end end end end FlexStationData::SampleDataApp.call(*ARGV)