Class: Rley::GFG::Edge

Inherits:
Object
  • Object
show all
Defined in:
lib/rley/gfg/edge.rb

Overview

Abstract class. Represents an edge in a grammar flow graph. Responsibilities:

  • To know the successor vertex

Direct Known Subclasses

CallEdge, EpsilonEdge, ReturnEdge, ScanEdge, ShortcutEdge

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(thePredecessor, theSuccessor) ⇒ Edge

Construct a directed edge between two given vertices

Parameters:



15
16
17
18
# File 'lib/rley/gfg/edge.rb', line 15

def initialize(thePredecessor, theSuccessor)
  @successor = theSuccessor
  thePredecessor&.add_edge(self)
end

Instance Attribute Details

#successorVertex (readonly)

Returns The destination vertex of the edge .

Returns:

  • (Vertex)

    The destination vertex of the edge .



10
11
12
# File 'lib/rley/gfg/edge.rb', line 10

def successor
  @successor
end

Instance Method Details

#inspectString

Returns a string containing a human-readable representation of the production.

Returns:

  • (String)


28
29
30
# File 'lib/rley/gfg/edge.rb', line 28

def inspect
  to_s
end

#to_sString

Returns:

  • (String)


21
22
23
# File 'lib/rley/gfg/edge.rb', line 21

def to_s
  " --> #{successor.label}"
end