class Pushdown::Transition

A transition in a Pushdown automaton

Attributes

name[R]

The name of the transition; mostly for human consumption

Public Class Methods

inherited( subclass ) click to toggle source

Inheritance hook – enable instantiation.

Calls superclass method
# 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
new( name ) click to toggle source

Create a new Transition with the given name.

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

Public Instance Methods

apply( stack ) click to toggle source

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
type_name() click to toggle source

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