Class: Ont::Instrument

Inherits:
ApplicationRecord show all
Includes:
Uuidable
Defined in:
app/models/ont/instrument.rb

Overview

Ont::Instrument

Constant Summary collapse

POSITION_NAME_MAP =

Contains position names for instrument_types

{
  PromethION: promethion_position_names,
  GridION: gridion_position_names
}.with_indifferent_access.freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Uuidable

#add_uuid

Class Method Details

.gridion_position_namesObject

Generates position names for gridION, x1..x5 Returns a hash where keys are position numbers and values are names.



67
68
69
# File 'app/models/ont/instrument.rb', line 67

def self.gridion_position_names
  (1..5).index_with { |i| "x#{i}" }
end

.promethion_position_namesObject

Generates position names for promethION, 1A..1H, 2A..2H, and 3A..3H Returns a hash where keys are position numbers and values are names.



56
57
58
59
60
61
62
63
# File 'app/models/ont/instrument.rb', line 56

def self.promethion_position_names
  position_names = (1..3).flat_map do |i|
    ('A'..'H').flat_map do |j|
      "#{i}#{j}"
    end
  end
  position_names.each_with_index.to_h { |v, i| [i + 1, v] }
end

Instance Method Details

#position_namesObject

Returns position names for instrument instance



50
51
52
# File 'app/models/ont/instrument.rb', line 50

def position_names
  POSITION_NAME_MAP[instrument_type]
end