class Diff::LCS::HTMLDiff::Callbacks

Attributes

match_class[RW]
only_a_class[RW]
only_b_class[RW]
output[RW]

Public Class Methods

new(output, options = {}) click to toggle source
# File lib/diff/lcs/htmldiff.rb, line 16
def initialize(output, options = {})
  @output = output
  options ||= {}

  @match_class = options[:match_class] || "match"
  @only_a_class = options[:only_a_class] || "only_a"
  @only_b_class = options[:only_b_class] || "only_b"
end

Public Instance Methods

discard_a(event) click to toggle source

This will be called when there is a line in A that isn’t in B

# File lib/diff/lcs/htmldiff.rb, line 37
def discard_a(event)
  @output << htmlize(event.old_element, :only_a_class)
end
discard_b(event) click to toggle source

This will be called when there is a line in B that isn’t in A

# File lib/diff/lcs/htmldiff.rb, line 42
def discard_b(event)
  @output << htmlize(event.new_element, :only_b_class)
end
match(event) click to toggle source

This will be called with both lines are the same

# File lib/diff/lcs/htmldiff.rb, line 32
def match(event)
  @output << htmlize(event.old_element, :match_class)
end