Class: CPEE::Transformation::Source::Graphviz

Inherits:
Object
  • Object
show all
Defined in:
lib/cpee/transformation/graphviz.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ Graphviz

{{{



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/cpee/transformation/graphviz.rb', line 30

def initialize(text) #{{{
  Node.class_variable_set(:@@niceid,  {})

  @tree = Tree.new
  @start = nil

  @dataelements = {}
  @endpoints = {}
  @graph = Graph.new

  extract_nodelink(text)

  @traces = Traces.new [[@start]]
end

Instance Attribute Details

#dataelementsObject (readonly)

Returns the value of attribute dataelements.



28
29
30
# File 'lib/cpee/transformation/graphviz.rb', line 28

def dataelements
  @dataelements
end

#endpointsObject (readonly)

Returns the value of attribute endpoints.



28
29
30
# File 'lib/cpee/transformation/graphviz.rb', line 28

def endpoints
  @endpoints
end

#graphObject (readonly)

Returns the value of attribute graph.



28
29
30
# File 'lib/cpee/transformation/graphviz.rb', line 28

def graph
  @graph
end

#startObject (readonly)

Returns the value of attribute start.



28
29
30
# File 'lib/cpee/transformation/graphviz.rb', line 28

def start
  @start
end

#tracesObject (readonly)

Returns the value of attribute traces.



28
29
30
# File 'lib/cpee/transformation/graphviz.rb', line 28

def traces
  @traces
end

#treeObject (readonly)

Returns the value of attribute tree.



28
29
30
# File 'lib/cpee/transformation/graphviz.rb', line 28

def tree
  @tree
end

Instance Method Details

{{{



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/cpee/transformation/graphviz.rb', line 64

def extract_nodelink(text) #{{{
  text.each_line do |line|
    if line =~ /^\s*"([^"]+)"\[shape=([a-z]+)(\slabel="([^"]*)")?\]\s*;?/
      id = $1
      type = map_nodes($2,$4)
      label = id

      label.sub(/^'/,'')
      label.sub(/'$/,'')
      label.sub(/^"/,'')
      label.sub(/"$/,'')

      n = Node.new(0,id,type,label,0,1)
      @graph.add_node n

							@start = n if n.type == :startEvent && @start == nil
    end
  end
  text.each_line do |line|
    if line =~ /^\s*"([^"]+)"\s+->\s+"([^"]+)"(\s*\[(label="([^"]*)")?\])?\s*;?/
      lid = $1
      rid = $2
      cond = $5

							@graph.add_link Link.new(lid, rid, cond.nil? ? nil : cond)
    end
  end
end