Class: Arena
- Inherits:
-
Object
- Object
- Arena
- Defined in:
- lib/another_toy_robot/arena.rb
Instance Method Summary collapse
- #inbounds?(position) ⇒ Boolean
-
#initialize(width: 5, height: 5) ⇒ Arena
constructor
A new instance of Arena.
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
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 |