Class: Theseus::Algorithms::Base
- Inherits:
-
Object
- Object
- Theseus::Algorithms::Base
- Defined in:
- lib/theseus/algorithms/base.rb
Overview
A minimal abstract superclass for maze algorithms to descend from, mostly as a helper to provide some basic, common functionality.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#maze ⇒ Object
readonly
The maze object that the algorithm will operate on.
Instance Method Summary collapse
-
#initialize(maze, options = {}) ⇒ Base
constructor
Create a new algorithm object that will operate on the given maze.
-
#pending? ⇒ Boolean
Returns true if the algorithm has not yet completed.
-
#step ⇒ Object
Execute a single step of the algorithm.
Constructor Details
#initialize(maze, options = {}) ⇒ Base
Create a new algorithm object that will operate on the given maze.
12 13 14 15 |
# File 'lib/theseus/algorithms/base.rb', line 12 def initialize(maze, ={}) @maze = maze @pending = true end |
Instance Attribute Details
#maze ⇒ Object (readonly)
The maze object that the algorithm will operate on.
8 9 10 |
# File 'lib/theseus/algorithms/base.rb', line 8 def maze @maze end |
Instance Method Details
#pending? ⇒ Boolean
Returns true if the algorithm has not yet completed.
18 19 20 |
# File 'lib/theseus/algorithms/base.rb', line 18 def pending? @pending end |
#step ⇒ Object
Execute a single step of the algorithm. Return true if the algorithm is still pending, or false if it has completed.
25 26 27 28 |
# File 'lib/theseus/algorithms/base.rb', line 25 def step return false unless pending? do_step end |