class Pushdown::Transition::Push
A push transition – add an instance of a given State to the top of the state stack.
Attributes
data[R]
The data object to pass to the state_class
's constructor
state_class[R]
The State to push to.
Public Class Methods
new( name, state_class, data=nil )
click to toggle source
Create a transition that will Push
an instance of the given state_class
to the stack.
Calls superclass method
Pushdown::Transition::new
# File lib/pushdown/transition/push.rb, line 13 def initialize( name, state_class, data=nil ) super( name ) @state_class = state_class @data = data end
Public Instance Methods
apply( stack )
click to toggle source
Apply the transition to the given stack
.
# File lib/pushdown/transition/push.rb, line 35 def apply( stack ) state = self.state_class.new( self.data ) self.log.debug "pushing a new state: %p" % [ state ] stack.last.on_pause if stack.last stack.push( state ) state.on_start return stack end