Sha256: f1bf94f951fb6cbee69e7ac44d2f4ca15d0c79a520654bfa6a57f25462251ffe

Contents?: true

Size: 501 Bytes

Versions: 2

Compression:

Stored size: 501 Bytes

Contents

# frozen_string_literal: true

# Class to represent a single labyrinth square or node
module LabyrinthSolver
  class Node
    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

    def open? direction
      @paths[direction]
    end

    def cheese?
      @cheese
    end

    def close direction
      @paths[direction] = false
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
subparry_labyrinth_solver-1.1.0 lib/subparry_labyrinth_solver/node.rb
subparry_labyrinth_solver-1.0.4 lib/subparry_labyrinth_solver/node.rb