Sha256: a87ab487df784f0e6e3e655de4b3aad9af2ef43b4deaa69173397f9588fc0546

Contents?: true

Size: 691 Bytes

Versions: 5

Compression:

Stored size: 691 Bytes

Contents

module Hanoi
  module Jane
    class Animation
      include Enumerable

      attr_accessor :stacks, :disc, :from, :to, :height

      def initialize
        @stacks = [[0]]
        @disc = 0
        @from = 0
        @to = 1
        @height = 7

        yield self if block_given?

        @stacks = PaddedStacks.new @stacks, @height
        @lifter = Lifter.new @stacks[@from]
        @dropper = Dropper.new @stacks[@to], @disc
      end

      def each
        @lifter.each do |state|
          @stacks[@from] = state.to_a
          yield self
        end

        @dropper.each do |state|
          @stacks[@to] = state.to_a
          yield self
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
hanoi-jane-0.4.0 lib/hanoi/jane/animation/animation.rb
hanoi-jane-0.3.4 lib/hanoi/jane/animation/animation.rb
hanoi-jane-0.3.3 lib/hanoi/jane/animation/animation.rb
hanoi-jane-0.3.1 lib/hanoi/jane/animation/animation.rb
hanoi-jane-0.3.0 lib/hanoi/jane/animation/animation.rb