Class: DiagramGraph

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

Overview

RailRoady diagram structure

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDiagramGraph

Returns a new instance of DiagramGraph.



9
10
11
12
13
14
15
# File 'lib/railroady/diagram_graph.rb', line 9

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.



29
30
31
# File 'lib/railroady/diagram_graph.rb', line 29

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.



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

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.



27
28
29
# File 'lib/railroady/diagram_graph.rb', line 27

def show_label=(value)
  @show_label = value
end

Instance Method Details

#add_edge(edge) ⇒ Object



21
22
23
# File 'lib/railroady/diagram_graph.rb', line 21

def add_edge(edge)
  @edges << edge
end

#add_node(node) ⇒ Object



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

def add_node(node)
  @nodes << node
end

#to_dotObject

Generate DOT graph



32
33
34
35
36
37
# File 'lib/railroady/diagram_graph.rb', line 32

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)



40
41
42
43
# File 'lib/railroady/diagram_graph.rb', line 40

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