Class: ToyRobot::Table

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#robotoObject (readonly)

Returns the value of attribute roboto.



4
5
6
# File 'lib/toy_robot/table.rb', line 4

def roboto
  @roboto
end

#xObject (readonly)

Returns the value of attribute x.



4
5
6
# File 'lib/toy_robot/table.rb', line 4

def x
  @x
end

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

#edgesObject

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_limitsObject

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_limitsObject

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