Class: UML::Graphviz::Graph
- Inherits:
-
Object
- Object
- UML::Graphviz::Graph
- Defined in:
- lib/uml/graphviz_helper.rb
Instance Attribute Summary collapse
-
#default_edge_attributes ⇒ Object
readonly
Returns the value of attribute default_edge_attributes.
-
#default_graph_attributes ⇒ Object
readonly
Returns the value of attribute default_graph_attributes.
-
#default_node_attributes ⇒ Object
readonly
Returns the value of attribute default_node_attributes.
-
#edges ⇒ Object
Returns the value of attribute edges.
-
#nodes ⇒ Object
Returns the value of attribute nodes.
-
#subgraphs ⇒ Object
Returns the value of attribute subgraphs.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(type, name) ⇒ Graph
constructor
A new instance of Graph.
- #name_to_id(object) ⇒ Object
- #to_dot(indent = 0) ⇒ Object
Constructor Details
#initialize(type, name) ⇒ Graph
Returns a new instance of Graph.
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/uml/graphviz_helper.rb', line 21 def initialize(type, name) @name = name @type = type @subgraphs = {} @nodes = {} @edges = {} @default_graph_attributes = Attributes.new @default_node_attributes = Attributes.new @default_edge_attributes = Attributes.new end |
Instance Attribute Details
#default_edge_attributes ⇒ Object (readonly)
Returns the value of attribute default_edge_attributes.
17 18 19 |
# File 'lib/uml/graphviz_helper.rb', line 17 def default_edge_attributes @default_edge_attributes end |
#default_graph_attributes ⇒ Object (readonly)
Returns the value of attribute default_graph_attributes.
17 18 19 |
# File 'lib/uml/graphviz_helper.rb', line 17 def default_graph_attributes @default_graph_attributes end |
#default_node_attributes ⇒ Object (readonly)
Returns the value of attribute default_node_attributes.
17 18 19 |
# File 'lib/uml/graphviz_helper.rb', line 17 def default_node_attributes @default_node_attributes end |
#edges ⇒ Object
Returns the value of attribute edges.
16 17 18 |
# File 'lib/uml/graphviz_helper.rb', line 16 def edges @edges end |
#nodes ⇒ Object
Returns the value of attribute nodes.
16 17 18 |
# File 'lib/uml/graphviz_helper.rb', line 16 def nodes @nodes end |
#subgraphs ⇒ Object
Returns the value of attribute subgraphs.
16 17 18 |
# File 'lib/uml/graphviz_helper.rb', line 16 def subgraphs @subgraphs end |
Class Method Details
.name_to_id(object) ⇒ Object
48 49 50 |
# File 'lib/uml/graphviz_helper.rb', line 48 def self.name_to_id(object) '_' << object.to_s.gsub(/::/, '_') end |
Instance Method Details
#name_to_id(object) ⇒ Object
44 45 46 |
# File 'lib/uml/graphviz_helper.rb', line 44 def name_to_id(object) self.class.name_to_id object end |
#to_dot(indent = 0) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/uml/graphviz_helper.rb', line 32 def to_dot(indent = 0) result = '' result << ' ' * indent << "#{@type} #{@name} {\n" result << ' ' * (indent + 1) << "graph #{@default_graph_attributes.to_dot};\n" unless @default_graph_attributes.empty? result << ' ' * (indent + 1) << "node #{@default_node_attributes.to_dot};\n" unless @default_node_attributes.empty? result << ' ' * (indent + 1) << "edge #{@default_edge_attributes.to_dot};\n" unless @default_edge_attributes.empty? result << collection_to_dot(@subgraphs.values, indent) result << collection_to_dot(@nodes.values, indent) result << collection_to_dot(@edges.values, indent) result << ' ' * indent << '}' end |