Class: DotGraphFormatter
Constant Summary collapse
- @@default_node_shaper =
proc{|n| "box"}
- @@default_node_labeler =
proc{|n| n.inspect}
- @@default_link_labeler =
proc{|info| info ? info.inspect : nil}
Instance Method Summary collapse
-
#format(nodes, links) ⇒ Object
nodes is array of node objects links is either array of arrays [fromNode, toNode [, infoOnLink]], or objects with attributes :from, :to, :info.
-
#initialize(nodeShaper = nil, nodeLabeler = nil, linkLabeler = nil, size = "11,9", orientation = "landscape") ⇒ DotGraphFormatter
constructor
A new instance of DotGraphFormatter.
Constructor Details
#initialize(nodeShaper = nil, nodeLabeler = nil, linkLabeler = nil, size = "11,9", orientation = "landscape") ⇒ DotGraphFormatter
Returns a new instance of DotGraphFormatter.
6 7 8 9 10 11 12 |
# File 'lib/rpdf2txt-rockit/graphviz_dot.rb', line 6 def initialize(nodeShaper = nil, nodeLabeler = nil, linkLabeler = nil, size = "11,9", orientation = "landscape") @node_shaper = nodeShaper || @@default_node_shaper @node_labeler = nodeLabeler || @@default_node_labeler @link_labeler = linkLabeler || @@default_link_labeler @size, @orientation = size, orientation end |
Instance Method Details
#format(nodes, links) ⇒ Object
nodes is array of node objects links is either array of
arrays [fromNode, toNode [, infoOnLink]], or
objects with attributes :from, :to, :info
18 19 20 21 22 23 24 25 26 |
# File 'lib/rpdf2txt-rockit/graphviz_dot.rb', line 18 def format(nodes, links) DotGraph.new("digraph G {\n" + "size = #{@size.inspect}\n" + "orientation = #{@orientation}\n" + nodes.uniq.map {|n| format_node(n)}.join("\n") + "\n" + links.uniq.map {|l| format_link(l)}.join("\n") + "\n" + "}" ) end |