Module: ClosureTree::Digraphs::ClassMethods
- Defined in:
- lib/closure_tree/digraphs.rb
Instance Method Summary collapse
-
#to_dot_digraph(tree_scope) ⇒ Object
Renders the given scope as a DOT digraph, suitable for rendering by Graphviz.
Instance Method Details
#to_dot_digraph(tree_scope) ⇒ Object
Renders the given scope as a DOT digraph, suitable for rendering by Graphviz
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/closure_tree/digraphs.rb', line 16 def to_dot_digraph(tree_scope) id_to_instance = tree_scope.reduce({}) { |h, ea| h[ea.id] = ea; h } output = StringIO.new output << "digraph G {\n" tree_scope.each do |ea| if id_to_instance.key? ea._ct_parent_id output << " \"#{ea._ct_parent_id}\" -> \"#{ea._ct_id}\"\n" end output << " \"#{ea._ct_id}\" [label=\"#{ea.to_digraph_label}\"]\n" end output << "}\n" output.string end |