Class: Reflekt::ActionStack

Inherits:
Object
  • Object
show all
Defined in:
lib/action_stack.rb

Instance Method Summary collapse

Constructor Details

#initializeActionStack

Returns a new instance of ActionStack.



10
11
12
13
# File 'lib/action_stack.rb', line 10

def initialize()
  @bottom = nil
  @top = nil
end

Instance Method Details

#baseObject



19
20
21
# File 'lib/action_stack.rb', line 19

def base()
  @bottom
end

#peekObject



15
16
17
# File 'lib/action_stack.rb', line 15

def peek()
  @top
end

#push(action) ⇒ Action

Place Action at the top of stack.

Parameters:

  • action (Action)

    The action to place.

Returns:

  • (Action)

    The placed action.



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/action_stack.rb', line 29

def push(action)
  # First time? Place 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