Class: LabyrinthSolver::Node
- Inherits:
-
Object
- Object
- LabyrinthSolver::Node
- Defined in:
- lib/subparry_labyrinth_solver/node.rb
Instance Method Summary collapse
- #cheese? ⇒ Boolean
- #close(direction) ⇒ Object
-
#initialize(paths) ⇒ Node
constructor
A new instance of Node.
- #open?(direction) ⇒ Boolean
Constructor Details
#initialize(paths) ⇒ Node
Returns a new instance of Node.
6 7 8 9 10 11 |
# File 'lib/subparry_labyrinth_solver/node.rb', line 6 def initialize(paths) raise MissingPathsError if paths[:up].nil? || paths[:down].nil? || paths[:left].nil? || paths[:right].nil? @paths = paths @cheese = paths[:cheese] || false end |
Instance Method Details
#cheese? ⇒ Boolean
17 18 19 |
# File 'lib/subparry_labyrinth_solver/node.rb', line 17 def cheese? @cheese end |
#close(direction) ⇒ Object
21 22 23 |
# File 'lib/subparry_labyrinth_solver/node.rb', line 21 def close direction @paths[direction] = false end |
#open?(direction) ⇒ Boolean
13 14 15 |
# File 'lib/subparry_labyrinth_solver/node.rb', line 13 def open? direction @paths[direction] end |