Class: ActionStack
- Inherits:
-
Object
- Object
- ActionStack
- Defined in:
- lib/action_stack.rb
Overview
Track the actions in a shadow call stack.
Instance Method Summary collapse
- #base ⇒ Object
-
#initialize ⇒ ActionStack
constructor
A new instance of ActionStack.
- #peek ⇒ Object
-
#push(action) ⇒ Action
Place Action at the top of stack.
Constructor Details
#initialize ⇒ ActionStack
Returns a new instance of ActionStack.
9 10 11 12 |
# File 'lib/action_stack.rb', line 9 def initialize() @bottom = nil @top = nil end |
Instance Method Details
#base ⇒ Object
18 19 20 |
# File 'lib/action_stack.rb', line 18 def base() @bottom end |
#peek ⇒ Object
14 15 16 |
# File 'lib/action_stack.rb', line 14 def peek() @top end |
#push(action) ⇒ Action
Place Action at the top of stack.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/action_stack.rb', line 28 def push(action) # Place first action at bottom of stack. if @bottom.nil? @bottom = action # Connect subsequent actions to each other. else @top.parent = action action.child = @top end # Place action at top of stack. @top = action end |