Sha256: 543ada35c0643eb54fceed85bd3ae5871995a7c997a4823b20a051ce29f4c8da
Contents?: true
Size: 770 Bytes
Versions: 1
Compression:
Stored size: 770 Bytes
Contents
# frozen_string_literal: true require "csv" require "active_support/core_ext" require "flex_station_data/services/parse_plate" module FlexStationData class LoadPlates include Concerns::Service attr_reader :file def initialize(file) @file = file end def data CSV.read(file, headers: false).to_a end def data_blocks @data_blocks ||= data.each_with_object([]) do |row, blocks| blocks << [] if plate_row?(row) blocks.last&.push(row) end end def call data_blocks.each_with_index.map do |data_block, index| FlexStationData::ParsePlate.call(index + 1, data_block) end end private def plate_row?(row) row[0].to_s =~ /\A\s*Plate:\s*/i end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
flex-station-data-1.0.2 | lib/flex_station_data/services/load_plates.rb |