Class: CPEE::Transformation::Source::CPEE
- Inherits:
-
Object
- Object
- CPEE::Transformation::Source::CPEE
- Defined in:
- lib/cpee/transformation/cpee.rb
Instance Attribute Summary collapse
-
#dataelements ⇒ Object
readonly
Returns the value of attribute dataelements.
-
#endpoints ⇒ Object
readonly
Returns the value of attribute endpoints.
-
#graph ⇒ Object
readonly
Returns the value of attribute graph.
-
#start ⇒ Object
readonly
Returns the value of attribute start.
-
#traces ⇒ Object
readonly
Returns the value of attribute traces.
-
#tree ⇒ Object
readonly
Returns the value of attribute tree.
Instance Method Summary collapse
- #extract_original(text) ⇒ Object
- #id_find(nid) ⇒ Object
-
#initialize(text) ⇒ CPEE
constructor
A new instance of CPEE.
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
#dataelements ⇒ Object (readonly)
Returns the value of attribute dataelements.
29 30 31 |
# File 'lib/cpee/transformation/cpee.rb', line 29 def dataelements @dataelements end |
#endpoints ⇒ Object (readonly)
Returns the value of attribute endpoints.
29 30 31 |
# File 'lib/cpee/transformation/cpee.rb', line 29 def endpoints @endpoints end |
#graph ⇒ Object (readonly)
Returns the value of attribute graph.
29 30 31 |
# File 'lib/cpee/transformation/cpee.rb', line 29 def graph @graph end |
#start ⇒ Object (readonly)
Returns the value of attribute start.
29 30 31 |
# File 'lib/cpee/transformation/cpee.rb', line 29 def start @start end |
#traces ⇒ Object (readonly)
Returns the value of attribute traces.
29 30 31 |
# File 'lib/cpee/transformation/cpee.rb', line 29 def traces @traces end |
#tree ⇒ Object (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 |