Class: Arena

Inherits:
Object
  • Object
show all
Defined in:
lib/another_toy_robot/arena.rb

Instance Method Summary collapse

Constructor Details

#initialize(width: 5, height: 5) ⇒ Arena

Returns a new instance of Arena.



2
3
4
5
# File 'lib/another_toy_robot/arena.rb', line 2

def initialize(width: 5, height: 5)
  @columns = 0...width
  @rows    = 0...height
end

Instance Method Details

#inbounds?(position) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/another_toy_robot/arena.rb', line 7

def inbounds?(position)
  @columns.cover?(position.x_coord) && @rows.cover?(position.y_coord)
end