lib/cpee/processtransformation/structures.rb in cpee-1.3.158 vs lib/cpee/processtransformation/structures.rb in cpee-1.3.159

- old
+ new

@@ -269,10 +269,15 @@ def remove(trcs) trcs.each do |t| self.delete(t) end end + def remove_by_endnode(enode) + self.delete_if do |t| + t[0] != enode + end + end def empty! self.delete_if{true} end @@ -309,18 +314,17 @@ def same_first (n = self.map{|t| t.first }.uniq).length == 1 ? n.first : nil end # future use - def incoming - if node = self.same_first - tcount = 1 - self.each{|t| tcount += 1 if t.first == t.last } - tcount - else - raise "Wrong Question" + def incoming(node) + tcount = 1 + self.each do |t| + break if t.length == 1 + tcount += 1 if t.last == node end + tcount end def include_in_all?(e) num = 0 self.each{|n| num += 1 if n.include?(e)} @@ -339,15 +343,16 @@ end def add_breaks(context) trueloops = self.find_all{ |t| t.last == t.first }.length + tb = Break.new(context,1) if trueloops == self.length self << [self.first_node] ### the blank conditional so that we get a break else self.each do |t| - t << Break.new(context,1) unless t.last == t.first ### an explicit break + t << tb unless t.last == t.first ### an explicit break end end end def loops @@ -437,10 +442,11 @@ end def find_endnode # supress loops trcs = self.dup - # trcs.delete_if { |t| t.uniq.length < t.length } + # dangerous TODO + trcs.delete_if { |t| t.uniq.length < t.length } # find common node (except loops) enode = nil unless trcs.empty? trcs.first.each do |n|