Class: OpenTrons::Instruments
- Inherits:
-
Object
- Object
- OpenTrons::Instruments
- Defined in:
- lib/opentrons/instruments.rb
Instance Attribute Summary collapse
-
#instrument_hash ⇒ Object
Returns the value of attribute instrument_hash.
-
#protocol ⇒ Object
Returns the value of attribute protocol.
Instance Method Summary collapse
- #add_pipette(model, mount: "left", tip_racks: [], tip_model: nil) ⇒ Object
-
#initialize(protocol) ⇒ Instruments
constructor
A new instance of Instruments.
- #inspect ⇒ Object
- #to_hash ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(protocol) ⇒ Instruments
Returns a new instance of Instruments.
16 17 18 19 |
# File 'lib/opentrons/instruments.rb', line 16 def initialize(protocol) @protocol = protocol @instrument_hash = {} end |
Instance Attribute Details
#instrument_hash ⇒ Object
Returns the value of attribute instrument_hash.
14 15 16 |
# File 'lib/opentrons/instruments.rb', line 14 def instrument_hash @instrument_hash end |
#protocol ⇒ Object
Returns the value of attribute protocol.
14 15 16 |
# File 'lib/opentrons/instruments.rb', line 14 def protocol @protocol end |
Instance Method Details
#add_pipette(model, mount: "left", tip_racks: [], tip_model: nil) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/opentrons/instruments.rb', line 33 def add_pipette(model, mount: "left", tip_racks: [], tip_model: nil) instrument_hash.each do |key, item| if item.mount == mount raise ArgumentError.new "Cannot place #{model} on mount #{mount} (already occupied)." end end generated_id = "" loop do generated_id = model + "-" + rand(100000...999999).to_s break if !(instrument_hash.key? generated_id) end if model.include? "multi" pipette = MultiPipette.new(protocol, self, model, mount: mount, tip_racks: tip_racks, tip_model: tip_model) else pipette = Pipette.new(protocol, self, model, mount: mount, tip_racks: tip_racks, tip_model: tip_model) end instrument_hash[generated_id] = pipette return pipette end |
#inspect ⇒ Object
69 70 71 |
# File 'lib/opentrons/instruments.rb', line 69 def inspect to_s end |
#to_hash ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/opentrons/instruments.rb', line 57 def to_hash as_hash = {} instrument_hash.each do |key, item| as_hash[key] = item.to_hash end return as_hash end |
#to_s ⇒ Object
65 66 67 |
# File 'lib/opentrons/instruments.rb', line 65 def to_s "<OpenTrons::Instruments:0x#{self.__id__.to_s(16)}>" end |