Method: CPEE::ProcessTransformation::Traces#extend

Defined in:
lib/cpee/processtransformation/structures.rb

#extendObject



399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
# File 'lib/cpee/processtransformation/structures.rb', line 399

def extend
  # find largest common
  max = []
  sh = self.shortest
  sh = sh[0..-2] if sh.first == sh.last
  sh.each_with_index do |e,i|
    max << e if self.include_in_all?(e)
  end
  max = max.last

  # if last is the largest common do nothing
  # else append from last to largest common
  self.each do |t|
    unless t.last == max
      last = t.last
      if t.index(last) && t.index(max)
        (t.index(last) + 1).upto(t.index(max)) do |i|
          t << t[i]
        end
      end
    end
  end

  max
end