Class: ToyRobot::Table
- Inherits:
-
Object
- Object
- ToyRobot::Table
- Defined in:
- lib/toy_robot/table.rb
Instance Attribute Summary collapse
-
#roboto ⇒ Object
readonly
Returns the value of attribute roboto.
-
#x ⇒ Object
readonly
Returns the value of attribute x.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
Instance Method Summary collapse
-
#edges ⇒ Object
Returns a Hash with the limits for X and Y axis.
-
#initialize(x:, y:) ⇒ Table
constructor
A new instance of Table.
-
#x_limits ⇒ Object
Returns a hash with min and max values for X based on initial value.
-
#y_limits ⇒ Object
Returns a hash with min and max values for Y based on initial value.
Constructor Details
#initialize(x:, y:) ⇒ Table
Returns a new instance of Table.
6 7 8 9 |
# File 'lib/toy_robot/table.rb', line 6 def initialize(x:, y:) @x = x @y = y end |
Instance Attribute Details
#roboto ⇒ Object (readonly)
Returns the value of attribute roboto.
4 5 6 |
# File 'lib/toy_robot/table.rb', line 4 def roboto @roboto end |
#x ⇒ Object (readonly)
Returns the value of attribute x.
4 5 6 |
# File 'lib/toy_robot/table.rb', line 4 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y.
4 5 6 |
# File 'lib/toy_robot/table.rb', line 4 def y @y end |
Instance Method Details
#edges ⇒ Object
Returns a Hash with the limits for X and Y axis
12 13 14 |
# File 'lib/toy_robot/table.rb', line 12 def edges { x: x_limits, y: y_limits } end |
#x_limits ⇒ Object
Returns a hash with min and max values for X based on initial value
17 18 19 |
# File 'lib/toy_robot/table.rb', line 17 def x_limits { min: 0, max: @x-1 } end |
#y_limits ⇒ Object
Returns a hash with min and max values for Y based on initial value
22 23 24 |
# File 'lib/toy_robot/table.rb', line 22 def y_limits { min: 0, max: @y-1 } end |