Transition

class
Superclass
Object

A transition in a Pushdown automaton

Attributes

name[R]

The name of the transition; mostly for human consumption

Public Class Methods

anchor
inherited( subclass )

Inheritance hook – enable instantiation.

# File lib/pushdown/transition.rb, line 28
def self::inherited( subclass )
        super
        subclass.public_class_method( :new )
        if (( type_name = subclass.name&.sub( /.*::/, '' )&.downcase ))
                Pushdown::State.register_transition( type_name )
        end
end
anchor
new( name )

Create a new Transition with the given name.

# File lib/pushdown/transition.rb, line 38
def initialize( name )
        @name = name
end

Public Instance Methods

anchor
apply( stack )

Return a state stack after the transition has been applied.

# File lib/pushdown/transition.rb, line 53
def apply( stack )
        raise NotImplementedError, "%p doesn't implement required method #%p" %
                [ self.class, __method__ ]
end
anchor
type_name()

Return the transition's type as a lowercase Symbol, such as that specified in transition declarations.

# File lib/pushdown/transition.rb, line 61
def type_name
        class_name = self.class.name or return :anonymous
        return class_name.sub( /.*::/, '' ).downcase.to_sym
end