Class: Robot::Simulator::Table
- Inherits:
-
Object
- Object
- Robot::Simulator::Table
- 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
-
#dimensionX ⇒ Object
readonly
Returns the value of attribute dimensionX.
-
#dimensionY ⇒ Object
readonly
Returns the value of attribute dimensionY.
Instance Method Summary collapse
-
#initialize(dimensionX, dimensionY) ⇒ Table
constructor
A new instance of Table.
- #is_valid_coordinate?(coordinate) ⇒ Boolean
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
#dimensionX ⇒ Object (readonly)
Returns the value of attribute dimensionX.
5 6 7 |
# File 'lib/robot/simulator/table.rb', line 5 def dimensionX @dimensionX end |
#dimensionY ⇒ Object (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
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 |