Sha256: ce2e41dec4dab2d8a48cc06a2010b40854f3cad7f89543659553a2b72db1c510

Contents?: true

Size: 578 Bytes

Versions: 4

Compression:

Stored size: 578 Bytes

Contents

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.split { |row| row[0] == "Plate:" }.drop(1)
    end

    def call
      data_blocks.each_with_index.map do |data_block, index|
        FlexStationData::ParsePlate.call(index + 1, data_block)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
flex-station-data-0.3.2 lib/flex_station_data/services/load_plates.rb
flex-station-data-0.3.1 lib/flex_station_data/services/load_plates.rb
flex-station-data-0.3.0 lib/flex_station_data/services/load_plates.rb
flex-station-data-0.2.0 lib/flex_station_data/services/load_plates.rb