Class: Node
- Inherits:
-
Object
- Object
- Node
- Defined in:
- lib/subparry_labyrinth_solver/node.rb
Overview
Class to represent a single labyrinth square or node
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.
5 6 7 8 9 10 |
# File 'lib/subparry_labyrinth_solver/node.rb', line 5 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
16 17 18 |
# File 'lib/subparry_labyrinth_solver/node.rb', line 16 def cheese? @cheese end |
#close(direction) ⇒ Object
20 21 22 |
# File 'lib/subparry_labyrinth_solver/node.rb', line 20 def close direction @paths[direction] = false end |
#open?(direction) ⇒ Boolean
12 13 14 |
# File 'lib/subparry_labyrinth_solver/node.rb', line 12 def open? direction @paths[direction] end |