Class: LabyrinthSolver::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/subparry_labyrinth_solver/node.rb

Instance Method Summary collapse

Constructor Details

#initialize(paths) ⇒ Node

Returns a new instance of Node.

Raises:



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

Returns:

  • (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

Returns:

  • (Boolean)


13
14
15
# File 'lib/subparry_labyrinth_solver/node.rb', line 13

def open? direction
  @paths[direction]
end