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

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ CPEE

Returns a new instance of CPEE.



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

def initialize(text)
  @tree = Tree.new
  @start = nil
  @nids = []

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

  extract_original(text)

  if @start.nil?
    @traces = Traces.new [[]]
  else
    @traces = Traces.new [[@start]]
  end
end

Instance Attribute Details

#dataelementsObject (readonly)

Returns the value of attribute dataelements.



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

def dataelements
  @dataelements
end

#endpointsObject (readonly)

Returns the value of attribute endpoints.



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

def endpoints
  @endpoints
end

#graphObject (readonly)

Returns the value of attribute graph.



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

def graph
  @graph
end

#startObject (readonly)

Returns the value of attribute start.



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

def start
  @start
end

#tracesObject (readonly)

Returns the value of attribute traces.



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

def traces
  @traces
end

#treeObject (readonly)

Returns the value of attribute tree.



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

def tree
  @tree
end

Instance Method Details

#extract_original(text) ⇒ Object



167
168
169
170
171
172
173
174
# File 'lib/cpee/transformation/cpee.rb', line 167

def extract_original(text)
  doc = XML::Smart::string(text)
  doc.register_namespace :d, 'http://cpee.org/ns/description/1.0'
  bn = dive doc.root
  ne = Node.new(0,Digest::MD5.hexdigest(Kernel::rand().to_s),:endEvent,'',1,0)
  @graph.add_node ne
  @graph.add_link Link.new(bn.id, ne.id)
end

#id_find(nid) ⇒ Object



49
50
51
52
53
54
55
56
# File 'lib/cpee/transformation/cpee.rb', line 49

def id_find(nid)
  nid = 'g0' unless nid
  while @nids.include?(nid)
    nid.next!
  end
  @nids << nid
  nid
end