Class: DiagramGraph

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

Overview

RailRoad diagram structure

Instance Method Summary collapse

Constructor Details

#initializeDiagramGraph

Returns a new instance of DiagramGraph.



11
12
13
14
15
16
# File 'lib/railroad/diagram_graph.rb', line 11

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

Instance Method Details

#add_edge(edge) ⇒ Object



22
23
24
# File 'lib/railroad/diagram_graph.rb', line 22

def add_edge(edge)
  @edges << edge
end

#add_node(node) ⇒ Object



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

def add_node(node)
  @nodes << node
end

#diagram_type=(type) ⇒ Object



26
27
28
# File 'lib/railroad/diagram_graph.rb', line 26

def diagram_type= (type)
  @diagram_type = type
end

#show_label=(value) ⇒ Object



30
31
32
# File 'lib/railroad/diagram_graph.rb', line 30

def show_label= (value)
  @show_label = value
end

#to_dotObject

Generate DOT graph



36
37
38
39
40
41
# File 'lib/railroad/diagram_graph.rb', line 36

def to_dot
  return dot_header +
         @nodes.map{|n| dot_node n[0], n[1], n[2]}.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)



44
45
46
47
# File 'lib/railroad/diagram_graph.rb', line 44

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