Class: Robotoy::Table
- Inherits:
-
Object
- Object
- Robotoy::Table
- Defined in:
- lib/robotoy/table.rb
Instance Attribute Summary collapse
-
#x ⇒ Object
readonly
Returns the value of attribute x.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
Instance Method Summary collapse
-
#initialize(x: 4, y: 4) ⇒ Table
constructor
A new instance of Table.
- #validate_next_position(x: 0, y: 0) ⇒ Object
Constructor Details
#initialize(x: 4, y: 4) ⇒ Table
Returns a new instance of Table.
5 6 7 8 |
# File 'lib/robotoy/table.rb', line 5 def initialize(x: 4, y: 4) @x = x @y = y end |
Instance Attribute Details
#x ⇒ Object (readonly)
Returns the value of attribute x.
3 4 5 |
# File 'lib/robotoy/table.rb', line 3 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y.
3 4 5 |
# File 'lib/robotoy/table.rb', line 3 def y @y end |
Instance Method Details
#validate_next_position(x: 0, y: 0) ⇒ Object
10 11 12 |
# File 'lib/robotoy/table.rb', line 10 def validate_next_position(x: 0, y: 0) raise NotValidMoveError unless x.between?(0, @x) && y.between?(0, @y) end |