Class: MazeMagic::Generate

Inherits:
Object
  • Object
show all
Defined in:
lib/maze_magic/generate.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(height:, width:, **options) ⇒ Generate

Returns a new instance of Generate.



6
7
8
9
10
# File 'lib/maze_magic/generate.rb', line 6

def initialize(height:, width:, **options)
  @height = height
  @width  = width
  @options = options
end

Instance Attribute Details

#algorithmObject



18
19
20
# File 'lib/maze_magic/generate.rb', line 18

def algorithm
  @algorithm ||= MazeMagic::MazeGenerator::RecursiveBacktracking
end

#heightObject (readonly)

Returns the value of attribute height.



3
4
5
# File 'lib/maze_magic/generate.rb', line 3

def height
  @height
end

#mazeObject (readonly)

Returns the value of attribute maze.



3
4
5
# File 'lib/maze_magic/generate.rb', line 3

def maze
  @maze
end

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'lib/maze_magic/generate.rb', line 3

def options
  @options
end

#widthObject (readonly)

Returns the value of attribute width.



3
4
5
# File 'lib/maze_magic/generate.rb', line 3

def width
  @width
end

Instance Method Details

#generate_mazeObject



12
13
14
15
16
# File 'lib/maze_magic/generate.rb', line 12

def generate_maze
  initialize_instructions_grid
  generate_maze_cells_from_instructions
  maze
end