Class: RGL::DOT::Edge
Overview
This is an undirected edge representation.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#from ⇒ Object
A node or subgraph reference or instance to be used as the starting point for an edge.
-
#to ⇒ Object
A node or subgraph reference or instance to be used as the ending point for an edge.
Attributes inherited from Element
Instance Method Summary collapse
-
#initialize(params = {}, option_list = EDGE_OPTS+EDGE_OPTS_LGCY) ⇒ Edge
constructor
Creates a new Edge with the params Hash providing settings for all edge options.
-
#to_s(leader = '', indent = ' ') ⇒ Object
Returns a string representation of this edge which is consumable by the graphviz tools
dotandneato.
Constructor Details
#initialize(params = {}, option_list = EDGE_OPTS+EDGE_OPTS_LGCY) ⇒ Edge
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.
486 487 488 489 490 |
# File 'lib/rgl/rdot.rb', line 486 def initialize(params = {}, option_list = EDGE_OPTS+EDGE_OPTS_LGCY) super(params, option_list) @from = params['from'] ? params['from'] : nil @to = params['to'] ? params['to'] : nil end |
Instance Attribute Details
#from ⇒ Object
A node or subgraph reference or instance to be used as the starting point for an edge.
476 477 478 |
# File 'lib/rgl/rdot.rb', line 476 def from @from end |
#to ⇒ Object
A node or subgraph reference or instance to be used as the ending point for an edge.
480 481 482 |
# File 'lib/rgl/rdot.rb', line 480 def to @to end |
Instance Method Details
#to_s(leader = '', indent = ' ') ⇒ Object
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.
497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 |
# File 'lib/rgl/rdot.rb', line 497 def to_s(leader = '', indent = ' ') = @options.collect do |name, val| unless val.nil? leader + indent + "#{quote_ID(name)} = #{quote_ID(val)}" end end.compact.join(",\n") f_s = @from || '' t_s = @to || '' if .empty? leader + quote_ID(f_s) + ' ' + edge_link + ' ' + quote_ID(t_s) else leader + quote_ID(f_s) + ' ' + edge_link + ' ' + quote_ID(t_s) + " [\n" + + "\n" + leader + "]" end end |