class Hanoi::Jane::Lifter
Attributes
lifted[R]
Public Class Methods
new(stack)
click to toggle source
# File lib/hanoi/jane/animation/lifter.rb, line 6 def initialize stack stack.map { |i| self.push i } @lifted = false end
position(stack)
click to toggle source
# File lib/hanoi/jane/animation/lifter.rb, line 33 def Lifter.position stack pos = nil stack.reverse.each_with_index do |item, index| if item pos = index break end end stack.length - 1 - pos end
Public Instance Methods
each() { |self| ... }
click to toggle source
# File lib/hanoi/jane/animation/lifter.rb, line 26 def each until @lifted lift yield self end end
lift()
click to toggle source
# File lib/hanoi/jane/animation/lifter.rb, line 12 def lift start = Lifter.position self item = self[start] self[start] = nil next_pos = start + 1 if next_pos >= self.length @lifted = true else self[next_pos] = item end end