Method: Traceable#get_diff

Defined in:
lib/wortsammler/class.Traceable.rb

#get_diff(other) ⇒ Object



372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
# File 'lib/wortsammler/class.Traceable.rb', line 372

def get_diff(other)
  newval = self.get_comparison_string
  oldval = other.get_comparison_string

  #todo: get it back as soon as amatch is available
  similarity = "n/a"
  #similarity=newval.levenshtein_similar(oldval).to_s[0..6]

  if newval == oldval
    result = nil
  else
    diff_as_html = "<pre>#{other.trace_orig}</pre><hr/><pre>#{self.trace_orig}</pre>" #Diffy::Diff.new(other.trace_orig, self.trace_orig).to_s(:text)
    rawDiff      = Diffy::Diff.new(self.trace_orig, other.trace_orig)
    diff_as_html = rawDiff.to_s(:html)

    result       = [self.id, similarity, diff_as_html]
    diff_as_html = nil
  end
  result
end