Sha256: 08b87a745cf99e69d6165b9139380afea72cb33eff2d6bc4d6b8b1846bd1f8cc

Contents?: true

Size: 495 Bytes

Versions: 2

Compression:

Stored size: 495 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.map(&FlexStationData::ParsePlate)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
flex-station-data-0.1.1 lib/flex_station_data/services/load_plates.rb
flex-station-data-0.1.0 lib/flex_station_data/services/load_plates.rb