A push transition – add an instance of a given State to the top of the state stack.
The data object to pass to the state_class
's constructor
The State to push to.
Create a transition that will Push
an instance of the given state_class
to the stack.
# File lib/pushdown/transition/push.rb, line 13
def initialize( name, state_class, data=nil )
super( name )
@state_class = state_class
@data = data
end
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