Class: Robotoy::Table

Inherits:
Object
  • Object
show all
Defined in:
lib/robotoy/table.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#xObject (readonly)

Returns the value of attribute x.



3
4
5
# File 'lib/robotoy/table.rb', line 3

def x
  @x
end

#yObject (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

Raises:



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