Class: Maze
- Inherits:
-
Object
- Object
- Maze
- Defined in:
- lib/my_own_maze/model/maze.rb
Instance Attribute Summary collapse
-
#end_point ⇒ Object
Returns the value of attribute end_point.
-
#height ⇒ Object
Returns the value of attribute height.
-
#points ⇒ Object
Returns the value of attribute points.
-
#start_point ⇒ Object
Returns the value of attribute start_point.
-
#width ⇒ Object
Returns the value of attribute width.
Instance Method Summary collapse
- #find_point(x, y) ⇒ Object
- #has_point?(x, y) ⇒ Boolean
-
#initialize(width, height, points, start_point, end_point) ⇒ Maze
constructor
A new instance of Maze.
- #is_end?(x, y) ⇒ Boolean
Constructor Details
#initialize(width, height, points, start_point, end_point) ⇒ Maze
Returns a new instance of Maze.
4 5 6 7 8 9 10 |
# File 'lib/my_own_maze/model/maze.rb', line 4 def initialize(width, height, points, start_point, end_point) @width = width @height = height @points = points @start_point = start_point @end_point = end_point end |
Instance Attribute Details
#end_point ⇒ Object
Returns the value of attribute end_point.
2 3 4 |
# File 'lib/my_own_maze/model/maze.rb', line 2 def end_point @end_point end |
#height ⇒ Object
Returns the value of attribute height.
2 3 4 |
# File 'lib/my_own_maze/model/maze.rb', line 2 def height @height end |
#points ⇒ Object
Returns the value of attribute points.
2 3 4 |
# File 'lib/my_own_maze/model/maze.rb', line 2 def points @points end |
#start_point ⇒ Object
Returns the value of attribute start_point.
2 3 4 |
# File 'lib/my_own_maze/model/maze.rb', line 2 def start_point @start_point end |
#width ⇒ Object
Returns the value of attribute width.
2 3 4 |
# File 'lib/my_own_maze/model/maze.rb', line 2 def width @width end |
Instance Method Details
#find_point(x, y) ⇒ Object
12 13 14 |
# File 'lib/my_own_maze/model/maze.rb', line 12 def find_point(x, y) @points.find { |point| point.x == x && point.y == y } end |
#has_point?(x, y) ⇒ Boolean
16 17 18 |
# File 'lib/my_own_maze/model/maze.rb', line 16 def has_point?(x, y) @points.find { |point| point.x == x && point.y == y } end |
#is_end?(x, y) ⇒ Boolean
20 21 22 |
# File 'lib/my_own_maze/model/maze.rb', line 20 def is_end?(x, y) @end_point.x == x && @end_point.y == y end |