Class: FlexStationData::LoadPlates
- Inherits:
-
Object
- Object
- FlexStationData::LoadPlates
- Includes:
- Callable
- Defined in:
- lib/flex_station_data/services/load_plates.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Instance Method Summary collapse
- #call ⇒ Object
- #data ⇒ Object
- #data_blocks ⇒ Object
-
#initialize(file) ⇒ LoadPlates
constructor
A new instance of LoadPlates.
Constructor Details
#initialize(file) ⇒ LoadPlates
Returns a new instance of LoadPlates.
14 15 16 |
# File 'lib/flex_station_data/services/load_plates.rb', line 14 def initialize(file) @file = file end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
12 13 14 |
# File 'lib/flex_station_data/services/load_plates.rb', line 12 def file @file end |
Instance Method Details
#call ⇒ Object
29 30 31 32 33 |
# File 'lib/flex_station_data/services/load_plates.rb', line 29 def call data_blocks.each_with_index.map do |data_block, index| FlexStationData::ParsePlate.call(index + 1, data_block) end end |
#data ⇒ Object
18 19 20 |
# File 'lib/flex_station_data/services/load_plates.rb', line 18 def data CSV.read(file, headers: false).to_a end |
#data_blocks ⇒ Object
22 23 24 25 26 27 |
# File 'lib/flex_station_data/services/load_plates.rb', line 22 def data_blocks @data_blocks ||= data.each_with_object([]) do |row, blocks| blocks << [] if plate_row?(row) blocks.last&.push(row) end end |