Class: VisualizeRuby::Graphviz

Inherits:
Object
  • Object
show all
Defined in:
lib/visualize_ruby/graphviz.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(graphs, label: nil) ⇒ Graphviz

Returns a new instance of Graphviz.



7
8
9
10
# File 'lib/visualize_ruby/graphviz.rb', line 7

def initialize(graphs, label: nil)
  @graphs = [*graphs]
  @label  = label
end

Instance Attribute Details

#graphsObject (readonly)

Returns the value of attribute graphs.



5
6
7
# File 'lib/visualize_ruby/graphviz.rb', line 5

def graphs
  @graphs
end

Instance Method Details

#to_graph(format: nil, path: nil) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/visualize_ruby/graphviz.rb', line 12

def to_graph(format: nil, path: nil)
  build
  if format == String
    str = StringIO.new
    main_graph.dump_graph(str)
    str.string
  else
    ::Graphviz.output(main_graph, path: path, format: format)
  end
end