Class: Diff::LCS::HTMLDiff::Callbacks

Inherits:
Object
  • Object
show all
Defined in:
lib/diff/lcs/htmldiff.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output, options = {}) ⇒ Callbacks

Returns a new instance of Callbacks.



18
19
20
21
22
23
24
25
# File 'lib/diff/lcs/htmldiff.rb', line 18

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

Instance Attribute Details

#match_classObject

Returns the value of attribute match_class.



14
15
16
# File 'lib/diff/lcs/htmldiff.rb', line 14

def match_class
  @match_class
end

#only_a_classObject

Returns the value of attribute only_a_class.



15
16
17
# File 'lib/diff/lcs/htmldiff.rb', line 15

def only_a_class
  @only_a_class
end

#only_b_classObject

Returns the value of attribute only_b_class.



16
17
18
# File 'lib/diff/lcs/htmldiff.rb', line 16

def only_b_class
  @only_b_class
end

#outputObject

Returns the value of attribute output.



13
14
15
# File 'lib/diff/lcs/htmldiff.rb', line 13

def output
  @output
end

Instance Method Details

#discard_a(event) ⇒ Object

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



39
40
41
# File 'lib/diff/lcs/htmldiff.rb', line 39

def discard_a(event)
  @output << htmlize(event.old_element, :only_a_class)
end

#discard_b(event) ⇒ Object

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



44
45
46
# File 'lib/diff/lcs/htmldiff.rb', line 44

def discard_b(event)
  @output << htmlize(event.new_element, :only_b_class)
end

#match(event) ⇒ Object

This will be called with both lines are the same



34
35
36
# File 'lib/diff/lcs/htmldiff.rb', line 34

def match(event)
  @output << htmlize(event.old_element, :match_class)
end