class OpenTrons::LabwareItem

Attributes

definition[RW]
display_name[RW]
labware[RW]
model[RW]
slot[RW]
well_list[RW]

Public Class Methods

new(labware, model, slot, display_name) click to toggle source
# 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

Public Instance Methods

inspect() click to toggle source
# File lib/opentrons/labware.rb, line 114
def inspect
        to_s
end
to_hash() click to toggle source
# 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() click to toggle source
# File lib/opentrons/labware.rb, line 110
def to_s
        "<OpenTrons::LabwareItem:0x#{self.__id__.to_s(16)}>"
end
wells(location=nil) click to toggle source
# 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