Class: OpenTrons::LabwareItem
- Inherits:
-
Object
- Object
- OpenTrons::LabwareItem
- Defined in:
- lib/opentrons/labware.rb
Instance Attribute Summary collapse
-
#definition ⇒ Object
Returns the value of attribute definition.
-
#display_name ⇒ Object
Returns the value of attribute display_name.
-
#labware ⇒ Object
Returns the value of attribute labware.
-
#model ⇒ Object
Returns the value of attribute model.
-
#slot ⇒ Object
Returns the value of attribute slot.
-
#well_list ⇒ Object
Returns the value of attribute well_list.
Instance Method Summary collapse
-
#initialize(labware, model, slot, display_name) ⇒ LabwareItem
constructor
A new instance of LabwareItem.
- #inspect ⇒ Object
- #to_hash ⇒ Object
- #to_s ⇒ Object
- #wells(location = nil) ⇒ Object
Constructor Details
#initialize(labware, model, slot, display_name) ⇒ LabwareItem
Returns a new instance of LabwareItem.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/opentrons/labware.rb', line 59 def initialize(labware, model, slot, display_name) if labware.labware_hash.map {|key, item| item.slot}.include? slot raise ArgumentError.new "Cannot place #{display_name} in slot #{slot} (already occupied)." end @labware = labware @model = model @slot = slot @display_name = display_name @definition = labware.labware_definitions.find{|x| x["metadata"]["name"] == model} @well_list = [] definition["ordering"].each do |column| well_list << column.map {|x| Well.new(self, x)} end end |
Instance Attribute Details
#definition ⇒ Object
Returns the value of attribute definition.
57 58 59 |
# File 'lib/opentrons/labware.rb', line 57 def definition @definition end |
#display_name ⇒ Object
Returns the value of attribute display_name.
57 58 59 |
# File 'lib/opentrons/labware.rb', line 57 def display_name @display_name end |
#labware ⇒ Object
Returns the value of attribute labware.
57 58 59 |
# File 'lib/opentrons/labware.rb', line 57 def labware @labware end |
#model ⇒ Object
Returns the value of attribute model.
57 58 59 |
# File 'lib/opentrons/labware.rb', line 57 def model @model end |
#slot ⇒ Object
Returns the value of attribute slot.
57 58 59 |
# File 'lib/opentrons/labware.rb', line 57 def slot @slot end |
#well_list ⇒ Object
Returns the value of attribute well_list.
57 58 59 |
# File 'lib/opentrons/labware.rb', line 57 def well_list @well_list end |
Instance Method Details
#inspect ⇒ Object
114 115 116 |
# File 'lib/opentrons/labware.rb', line 114 def inspect to_s end |
#to_hash ⇒ Object
102 103 104 105 106 107 108 |
# File 'lib/opentrons/labware.rb', line 102 def to_hash as_hash = {} as_hash["model"] = model as_hash["slot"] = slot as_hash["display-name"] = display_name return as_hash end |
#to_s ⇒ Object
110 111 112 |
# File 'lib/opentrons/labware.rb', line 110 def to_s "<OpenTrons::LabwareItem:0x#{self.__id__.to_s(16)}>" end |
#wells(location = nil) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/opentrons/labware.rb', line 76 def wells(location=nil) if location.is_a? String well_list.each do |column| column.each do |x| if x.location == location return x end end end return ArgumentError.new "Well #{location} is out of range." elsif location.is_a? Integer i = location well_list.each do |column| column.each do |x| if i == 0 return x end i -= 1 end end return ArgumentError.new "Well #{location} is out of range." else return well_list.flatten end end |