Sha256: 91ee994aa47f3ea298b992ea25b800523e29efd0ec44f078899d751880ec5b38
Contents?: true
Size: 1 KB
Versions: 3
Compression:
Stored size: 1 KB
Contents
module Hanoi module Jane class AnimatedTowers include Enumerable attr_accessor :towers, :discs, :height def initialize yield self if block_given? if @discs > @height raise HanoiException.new 'number_of_discs (%d) > height (%d)' % [@discs, @height] end @towers = @towers.new @discs end def each until @towers.solved stacks = PaddedStacks.new @towers.stacks, @height value = @towers.rebased @towers.move yield Frame.new stacks, value, :key @anim = Animation.new do |a| a.stacks = stacks a.disc = @towers.disc a.from = @towers.from a.to = @towers.to a.height = @height end @anim.each do |frame| yield Frame.new frame.stacks, @towers.rebased, :tween end end yield Frame.new (PaddedStacks.new @towers.stacks, @height), @towers.rebased, :key end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
hanoi-jane-0.4.0 | lib/hanoi/jane/towers/animated_towers.rb |
hanoi-jane-0.3.4 | lib/hanoi/jane/towers/animated_towers.rb |
hanoi-jane-0.3.3 | lib/hanoi/jane/towers/animated_towers.rb |