123456789_123456789_123456789_123456789_123456789_

Class: Prism::DotVisitor::Digraph

Do not use. This class is for internal use only.
Relationships & Source Files
Inherits: Object
Defined in: lib/prism/dot_visitor.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.newDigraph

[ GitHub ]

  
# File 'lib/prism/dot_visitor.rb', line 66

def initialize
  @nodes = []
  @waypoints = []
  @edges = []
end

Instance Attribute Details

#edges (readonly)

[ GitHub ]

  
# File 'lib/prism/dot_visitor.rb', line 64

attr_reader :nodes, :waypoints, :edges

#nodes (readonly)

[ GitHub ]

  
# File 'lib/prism/dot_visitor.rb', line 64

attr_reader :nodes, :waypoints, :edges

#waypoints (readonly)

[ GitHub ]

  
# File 'lib/prism/dot_visitor.rb', line 64

attr_reader :nodes, :waypoints, :edges

Instance Method Details

#edge(value)

[ GitHub ]

  
# File 'lib/prism/dot_visitor.rb', line 80

def edge(value)
  edges << value
end

#node(value)

[ GitHub ]

  
# File 'lib/prism/dot_visitor.rb', line 72

def node(value)
  nodes << value
end

#to_dot

[ GitHub ]

  
# File 'lib/prism/dot_visitor.rb', line 84

def to_dot
  <<~DOT
    digraph "Prism" {
      node [
        fontname=\"Courier New\"
        shape=plain
        style=filled
        fillcolor=gray95
      ];

      #{nodes.map { |node| node.gsub(/\n/, "\n  ") }.join("\n  ")}
      node [shape=point];
      #{waypoints.join("\n  ")}

      #{edges.join("\n  ")}
    }
  DOT
end

#waypoint(value)

[ GitHub ]

  
# File 'lib/prism/dot_visitor.rb', line 76

def waypoint(value)
  waypoints << value
end