Class: Hanoi::Jane::Lifter
- Inherits:
-
Array
- Object
- Array
- Hanoi::Jane::Lifter
- Defined in:
- lib/hanoi/jane/animation/lifter.rb
Instance Attribute Summary collapse
-
#lifted ⇒ Object
readonly
Returns the value of attribute lifted.
Class Method Summary collapse
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(stack) ⇒ Lifter
constructor
A new instance of Lifter.
- #lift ⇒ Object
Constructor Details
#initialize(stack) ⇒ Lifter
Returns a new instance of Lifter.
6 7 8 9 10 |
# File 'lib/hanoi/jane/animation/lifter.rb', line 6 def initialize stack stack.map { |i| self.push i } @lifted = false end |
Instance Attribute Details
#lifted ⇒ Object (readonly)
Returns the value of attribute lifted.
4 5 6 |
# File 'lib/hanoi/jane/animation/lifter.rb', line 4 def lifted @lifted end |
Class Method Details
.position(stack) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# 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 |
Instance Method Details
#each ⇒ Object
26 27 28 29 30 31 |
# File 'lib/hanoi/jane/animation/lifter.rb', line 26 def each until @lifted lift yield self end end |