Sha256: faeb16c3043c91c2ce6fb68de5105ae531f01f658363c84470a8dc8b29d05c15
Contents?: true
Size: 803 Bytes
Versions: 1
Compression:
Stored size: 803 Bytes
Contents
module ScbiGo class BaseGraph #create a dot file and optional pdf file def initialize(nodes, file_name=nil, name='my_graph', generate_pdf=false) @graph_name=name if !nodes.empty? res =[] res += build_dot_lines(nodes) if !file_name.nil? f=File.new(file_name,'w') f.puts res f.close if generate_pdf system("dot -Tpdf #{file_name} -o #{file_name}.pdf") end end end end # define the way that nodes are painted in dot def build_dot_lines(nodes) res =[] res << "graph #{@graph_name} {" nodes.each do |node| res << "#{node.id.gsub(':','_')}[label=\"#{node.id}\n#{node.name}\"];" end res << "}" return res end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
scbi_go-0.0.1 | lib/scbi_go/base_graph.rb |