class RGL::DOT::Edge
This is an undirected edge representation.
Attributes
from[RW]
A node or subgraph reference or instance to be used as the starting point for an edge.
to[RW]
A node or subgraph reference or instance to be used as the ending point for an edge.
Public Class Methods
new(params = {}, option_list = EDGE_OPTS)
click to toggle source
Creates a new Edge
with the params Hash providing settings for all edge options. The option_list parameter restricts those options to the list of valid names it contains.
Calls superclass method
# File lib/rgl/rdot.rb 430 def initialize(params = {}, option_list = EDGE_OPTS) 431 super(params, option_list) 432 @from = params['from'] ? params['from'] : nil 433 @to = params['to'] ? params['to'] : nil 434 end
Public Instance Methods
to_s(leader = '', indent = ' ')
click to toggle source
Returns a string representation of this edge which is consumable by the graphviz tools dot
and neato
. The leader parameter is used to indent every line of the returned string, and the indent parameter is used to additionally indent nested items.
# File lib/rgl/rdot.rb 441 def to_s(leader = '', indent = ' ') 442 stringified_options = @options.collect do |name, val| 443 unless val.nil? 444 leader + indent + "#{quote_ID(name)} = #{quote_ID(val)}" 445 end 446 end.compact.join(",\n") 447 448 f_s = @from || '' 449 t_s = @to || '' 450 451 if stringified_options.empty? 452 leader + quote_ID(f_s) + ' ' + edge_link + ' ' + quote_ID(t_s) 453 else 454 leader + quote_ID(f_s) + ' ' + edge_link + ' ' + quote_ID(t_s) + " [\n" + 455 stringified_options + "\n" + 456 leader + "]" 457 end 458 end
Private Instance Methods
edge_link()
click to toggle source
# File lib/rgl/rdot.rb 462 def edge_link 463 '--' 464 end