Class: Maze

Inherits:
Object
  • Object
show all
Defined in:
lib/my_own_maze/model/maze.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_pointObject

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

#heightObject

Returns the value of attribute height.



2
3
4
# File 'lib/my_own_maze/model/maze.rb', line 2

def height
  @height
end

#pointsObject

Returns the value of attribute points.



2
3
4
# File 'lib/my_own_maze/model/maze.rb', line 2

def points
  @points
end

#start_pointObject

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

#widthObject

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

Returns:

  • (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

Returns:

  • (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