Class: PlateTemplateTask::SpreadsheetReader
- Inherits:
-
Object
- Object
- PlateTemplateTask::SpreadsheetReader
- Defined in:
- app/models/plate_template_task.rb
Overview
Class to extract the layout from an uploaded spreadsheet
Instance Method Summary collapse
-
#initialize(csv_string, batch, plate_size) ⇒ SpreadsheetReader
constructor
A new instance of SpreadsheetReader.
-
#layout ⇒ Object
rubocop:todo Metrics/MethodLength.
Constructor Details
#initialize(csv_string, batch, plate_size) ⇒ SpreadsheetReader
Returns a new instance of SpreadsheetReader.
8 9 10 11 12 |
# File 'app/models/plate_template_task.rb', line 8 def initialize(csv_string, batch, plate_size) @csv_string = csv_string @requests = batch.requests.includes(asset: [:map, { plate: :barcodes }]).index_by(&:id) @plate_size = plate_size end |
Instance Method Details
#layout ⇒ Object
rubocop:todo Metrics/MethodLength
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/models/plate_template_task.rb', line 15 def layout # rubocop:todo Metrics/AbcSize = Set.new plates = mapped_plate_wells.each_value.map do |mapped_wells| Array.new(plate_size) do |i| request_id = mapped_wells[i] if request_id.present? asset = requests[request_id].asset << asset.plate. [request_id, asset.plate., asset.display_name] else CherrypickTask::EMPTY_WELL end end end [plates, .to_a] end |