Pop

class
Superclass
Pushdown::Transition

A push transition – add an instance of a given State to the top of the state stack.

Attributes

popped_state[R]

Return the state that was popped

Public Instance Methods

anchor
apply( stack )

Apply the transition to the given stack.

# File lib/pushdown/transition/pop.rb, line 22
def apply( stack )
        raise Pushdown::TransitionError, "can't pop from an empty stack" if stack.empty?
        raise Pushdown::TransitionError, "can't pop the only state on the stack" if stack.length == 1

        self.log.debug "popping a state"
        @popped_state = stack.pop
        @popped_state.on_stop
        stack.last.on_resume

        return stack
end