Class: Rley::GFG::Edge
- Inherits:
-
Object
- Object
- Rley::GFG::Edge
- 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
Instance Attribute Summary collapse
-
#successor ⇒ Vertex
readonly
The destination vertex of the edge .
Instance Method Summary collapse
-
#initialize(thePredecessor, theSuccessor) ⇒ Edge
constructor
Construct a directed edge between two given vertices.
-
#inspect ⇒ String
Returns a string containing a human-readable representation of the production.
- #to_s ⇒ String
Constructor Details
#initialize(thePredecessor, theSuccessor) ⇒ Edge
Construct a directed edge between two given vertices
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
#successor ⇒ Vertex (readonly)
Returns The destination vertex of the edge .
10 11 12 |
# File 'lib/rley/gfg/edge.rb', line 10 def successor @successor end |
Instance Method Details
#inspect ⇒ String
Returns a string containing a human-readable representation of the production.
28 29 30 |
# File 'lib/rley/gfg/edge.rb', line 28 def inspect to_s end |
#to_s ⇒ String
21 22 23 |
# File 'lib/rley/gfg/edge.rb', line 21 def to_s " --> #{successor.label}" end |