Method: MazeCrosser::MazeCrosserRunner#run

Defined in:
lib/maze_crosser/maze_crosser_runner.rb

#run(file = nil, algorithm = 'recursive') ⇒ Object

Raises:

  • (ArgumentError)


21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/maze_crosser/maze_crosser_runner.rb', line 21

def run(file = nil, algorithm = 'recursive')
  # When an additional grid import method is implemented (e.g. via CLI)
  # the following should be done:
  # 1) The line that raises ArgumentError should be removed
  # 2) Grid assignment should be moved to a private method
  raise ArgumentError, 'Please provide a file' unless file

  grid = define(file) if file

  maze = MazeCrosser::Maze.new(grid)
  algorithm = load_algorithm(algorithm, maze)
  present_solution(MazeSolver.new(maze, algorithm, @cache_provider).solve)
end