class Traceable

Attributes

alternative_id[R]

string: the alternative Id, used e.g. for the constraint number

body_orig[RW]

String: he body in original format

body_plain[RW]

String: The body in plain text

category[RW]

String: category of the entry

contributes_to[R]

Array of Strings: The uplink as an array of Trace-ids

header_orig[RW]

String: The header in original format

header_plain[RW]

String: The header in plain text

id[R]

String: The trace-Id

info[RW]

String: info on the entry

origin[RW]

String: origin of the entry

trace_orig[RW]

String: the Traceable in its original format

Public Class Methods

new() click to toggle source
# File lib/wortsammler/class.Traceable.rb, line 342
def initialize()
  @id             = ""
  @alternative_id = ""
  @header_orig    = ""
  @body_plain     = ""
  @body_orig      = ""
  @contributes_to = []
  @trace_orig     = ""
  @category       = ""
  @info           = ""
end

Public Instance Methods

<=>(other) click to toggle source

define the comparison to makeit really comparable @param [Traceable] other the other traceable for comparison.

# File lib/wortsammler/class.Traceable.rb, line 368
def <=> (other)
  @id <=> other.id
end
alternative_id=() click to toggle source
# File lib/wortsammler/class.Traceable.rb, line 358
def alternative_id=()
  @alternative_id = clear_trace_id(id)
end
as_oneline() click to toggle source
# File lib/wortsammler/class.Traceable.rb, line 398
def as_oneline
  trace_orig.gsub(/\s+/, " ")
end
clear_trace_id(id) click to toggle source
# File lib/wortsammler/class.Traceable.rb, line 311
def clear_trace_id(id)
  id.gsub("\\_", "_")
end
contributes_to=(list) click to toggle source
# File lib/wortsammler/class.Traceable.rb, line 362
def contributes_to=(list)
  @contributes_to = list.map { |id| id = clear_trace_id(id) }
end
get_comparison_string() click to toggle source
# File lib/wortsammler/class.Traceable.rb, line 394
def get_comparison_string
  "#{header_orig};#{body_orig};#{contributes_to.sort}".gsub(/\s+/, " ")
end
get_diff(other) click to toggle source
# 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
id=(id) click to toggle source
# File lib/wortsammler/class.Traceable.rb, line 354
def id=(id)
  @id = clear_trace_id(id)
end