Class: Robot::Simulator::Table

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

Overview

Table with dimension, in which a robot can be placed and roam around.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dimensionX, dimensionY) ⇒ Table

Returns a new instance of Table.



7
8
9
# File 'lib/robot/simulator/table.rb', line 7

def initialize(dimensionX, dimensionY)
  @dimensionX, @dimensionY = dimensionX, dimensionY
end

Instance Attribute Details

#dimensionXObject (readonly)

Returns the value of attribute dimensionX.



5
6
7
# File 'lib/robot/simulator/table.rb', line 5

def dimensionX
  @dimensionX
end

#dimensionYObject (readonly)

Returns the value of attribute dimensionY.



5
6
7
# File 'lib/robot/simulator/table.rb', line 5

def dimensionY
  @dimensionY
end

Instance Method Details

#is_valid_coordinate?(coordinate) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
15
# File 'lib/robot/simulator/table.rb', line 11

def is_valid_coordinate?(coordinate)
  coordinate and
  coordinate.x >= 0 and coordinate.x < dimensionX and
  coordinate.y >= 0 and coordinate.y < dimensionY
end