Class: VisionMate::Rack
- Inherits:
-
Object
- Object
- VisionMate::Rack
- Includes:
- Enumerable
- Defined in:
- lib/vision_mate/rack.rb
Defined Under Namespace
Classes: PositionOutOfRange
Instance Attribute Summary collapse
-
#number_of_columns ⇒ Object
Returns the value of attribute number_of_columns.
-
#number_of_rows ⇒ Object
Returns the value of attribute number_of_rows.
-
#tubes ⇒ Object
Returns the value of attribute tubes.
Instance Method Summary collapse
- #at_position(position) ⇒ Object
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(tube_string) ⇒ Rack
constructor
A new instance of Rack.
Constructor Details
#initialize(tube_string) ⇒ Rack
Returns a new instance of Rack.
8 9 10 11 12 |
# File 'lib/vision_mate/rack.rb', line 8 def initialize(tube_string) self.number_of_rows = 8 self.number_of_columns = 12 self.tubes = new_rack(tube_string) end |
Instance Attribute Details
#number_of_columns ⇒ Object
Returns the value of attribute number_of_columns.
4 5 6 |
# File 'lib/vision_mate/rack.rb', line 4 def number_of_columns @number_of_columns end |
#number_of_rows ⇒ Object
Returns the value of attribute number_of_rows.
4 5 6 |
# File 'lib/vision_mate/rack.rb', line 4 def number_of_rows @number_of_rows end |
#tubes ⇒ Object
Returns the value of attribute tubes.
4 5 6 |
# File 'lib/vision_mate/rack.rb', line 4 def tubes @tubes end |
Instance Method Details
#at_position(position) ⇒ Object
18 19 20 21 |
# File 'lib/vision_mate/rack.rb', line 18 def at_position(position) tubes.find { |tube| tube.position == position } || raise(PositionOutOfRange) end |
#each(&block) ⇒ Object
14 15 16 |
# File 'lib/vision_mate/rack.rb', line 14 def each(&block) tubes.each(&block) end |
#empty? ⇒ Boolean
23 24 25 |
# File 'lib/vision_mate/rack.rb', line 23 def empty? tubes.all?(&:empty?) end |