Class: MazeCrosser::MazeCrosserRunner
- Inherits:
-
Object
- Object
- MazeCrosser::MazeCrosserRunner
- Includes:
- FileMazeDefiner, PresentationHelper
- Defined in:
- lib/maze_crosser/maze_crosser_runner.rb
Overview
Class responsible for running the application.
maze_crosser_runner = MazerRunner.new maze_crosser_runner.run(file, algorithm)
Constant Summary
Constants included from FileChecker
FileChecker::ALLOWED_EXTENSIONS
Instance Method Summary collapse
-
#initialize(cache_provider) ⇒ MazeCrosserRunner
constructor
A new instance of MazeCrosserRunner.
- #run(file = nil, algorithm = 'recursive') ⇒ Object
Methods included from FileMazeDefiner
Methods included from FileChecker
Methods included from PresentationHelper
Constructor Details
#initialize(cache_provider) ⇒ MazeCrosserRunner
Returns a new instance of MazeCrosserRunner.
17 18 19 |
# File 'lib/maze_crosser/maze_crosser_runner.rb', line 17 def initialize(cache_provider) @cache_provider = cache_provider end |
Instance Method Details
#run(file = nil, algorithm = 'recursive') ⇒ Object
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 |