Class: Diff::LCS::HTMLDiff::Callbacks
- Inherits:
-
Object
- Object
- Diff::LCS::HTMLDiff::Callbacks
- Defined in:
- lib/diff/lcs/htmldiff.rb
Instance Attribute Summary collapse
-
#match_class ⇒ Object
Returns the value of attribute match_class.
-
#only_a_class ⇒ Object
Returns the value of attribute only_a_class.
-
#only_b_class ⇒ Object
Returns the value of attribute only_b_class.
-
#output ⇒ Object
Returns the value of attribute output.
Instance Method Summary collapse
-
#discard_a(event) ⇒ Object
This will be called when there is a line in A that isn’t in B.
-
#discard_b(event) ⇒ Object
This will be called when there is a line in B that isn’t in A.
-
#initialize(output, options = {}) ⇒ Callbacks
constructor
A new instance of Callbacks.
-
#match(event) ⇒ Object
This will be called with both lines are the same.
Constructor Details
#initialize(output, options = {}) ⇒ Callbacks
Returns a new instance of Callbacks.
17 18 19 20 21 22 23 24 |
# File 'lib/diff/lcs/htmldiff.rb', line 17 def initialize(output, = {}) @output = output ||= {} @match_class = [:match_class] || "match" @only_a_class = [:only_a_class] || "only_a" @only_b_class = [:only_b_class] || "only_b" end |
Instance Attribute Details
#match_class ⇒ Object
Returns the value of attribute match_class.
13 14 15 |
# File 'lib/diff/lcs/htmldiff.rb', line 13 def match_class @match_class end |
#only_a_class ⇒ Object
Returns the value of attribute only_a_class.
14 15 16 |
# File 'lib/diff/lcs/htmldiff.rb', line 14 def only_a_class @only_a_class end |
#only_b_class ⇒ Object
Returns the value of attribute only_b_class.
15 16 17 |
# File 'lib/diff/lcs/htmldiff.rb', line 15 def only_b_class @only_b_class end |
#output ⇒ Object
Returns the value of attribute output.
12 13 14 |
# File 'lib/diff/lcs/htmldiff.rb', line 12 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
38 39 40 |
# File 'lib/diff/lcs/htmldiff.rb', line 38 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
43 44 45 |
# File 'lib/diff/lcs/htmldiff.rb', line 43 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
33 34 35 |
# File 'lib/diff/lcs/htmldiff.rb', line 33 def match(event) @output << htmlize(event.old_element, :match_class) end |