Class: DiagramGraph

Inherits:
Object
  • Object
show all
Defined in:
lib/railroady/diagram_graph.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDiagramGraph

Returns a new instance of DiagramGraph.



6
7
8
9
10
11
12
# File 'lib/railroady/diagram_graph.rb', line 6

def initialize
  @diagram_type = ''
  @show_label   = false
  @alphabetize  = false
  @nodes = []
  @edges = []
end

Instance Attribute Details

#alphabetize=(value) ⇒ Object (writeonly)

Sets the attribute alphabetize

Parameters:

  • value

    the value to set the attribute alphabetize to.



4
5
6
# File 'lib/railroady/diagram_graph.rb', line 4

def alphabetize=(value)
  @alphabetize = value
end

#diagram_type=(value) ⇒ Object (writeonly)

Sets the attribute diagram_type

Parameters:

  • value

    the value to set the attribute diagram_type to.



4
5
6
# File 'lib/railroady/diagram_graph.rb', line 4

def diagram_type=(value)
  @diagram_type = value
end

#show_label=(value) ⇒ Object (writeonly)

Sets the attribute show_label

Parameters:

  • value

    the value to set the attribute show_label to.



4
5
6
# File 'lib/railroady/diagram_graph.rb', line 4

def show_label=(value)
  @show_label = value
end

Instance Method Details

#add_edge(edge) ⇒ Object



18
19
20
# File 'lib/railroady/diagram_graph.rb', line 18

def add_edge(edge)
  @edges << edge
end

#add_node(node) ⇒ Object



14
15
16
# File 'lib/railroady/diagram_graph.rb', line 14

def add_node(node)
  @nodes << node
end

#to_dotObject

Generate DOT graph



23
24
25
26
27
28
# File 'lib/railroady/diagram_graph.rb', line 23

def to_dot
  dot_header +
    @nodes.map { |n| dot_node n[0], n[1], n[2], n[3] }.join +
    @edges.map { |e| dot_edge e[0], e[1], e[2], e[3] }.join +
    dot_footer
end

#to_xmiObject

Generate XMI diagram (not yet implemented)



31
32
33
34
# File 'lib/railroady/diagram_graph.rb', line 31

def to_xmi
  $stderr.print "Sorry. XMI output not yet implemented.\n\n"
  ''
end