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(builder_result = nil, graphs: nil, label: nil, unique_nodes: true, only_graphs: nil) ⇒ Graphviz

Returns a new instance of Graphviz.



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

def initialize(builder_result = nil, graphs: nil, label: nil, unique_nodes: true, only_graphs: nil)
  @graphs       = graphs || builder_result.graphs
  @label        = builder_result ? builder_result.options[:label] : label
  @unique_nodes = unique_nodes
  @only_graphs  = [*only_graphs]
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

#only_graphsObject (readonly)

Returns the value of attribute only_graphs.



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

def only_graphs
  @only_graphs
end

#unique_nodesObject (readonly)

Returns the value of attribute unique_nodes.



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

def unique_nodes
  @unique_nodes
end

Instance Method Details

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



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

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