Class: OpenTrons::LabwareItem

Inherits:
Object
  • Object
show all
Defined in:
lib/opentrons/labware.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#definitionObject

Returns the value of attribute definition.



57
58
59
# File 'lib/opentrons/labware.rb', line 57

def definition
  @definition
end

#display_nameObject

Returns the value of attribute display_name.



57
58
59
# File 'lib/opentrons/labware.rb', line 57

def display_name
  @display_name
end

#labwareObject

Returns the value of attribute labware.



57
58
59
# File 'lib/opentrons/labware.rb', line 57

def labware
  @labware
end

#modelObject

Returns the value of attribute model.



57
58
59
# File 'lib/opentrons/labware.rb', line 57

def model
  @model
end

#slotObject

Returns the value of attribute slot.



57
58
59
# File 'lib/opentrons/labware.rb', line 57

def slot
  @slot
end

#well_listObject

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

#inspectObject



114
115
116
# File 'lib/opentrons/labware.rb', line 114

def inspect
	to_s
end

#to_hashObject



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_sObject



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