Class: SimpleCorrectionDiff
- Inherits:
-
Object
- Object
- SimpleCorrectionDiff
- Includes:
- ERB::Util
- Defined in:
- lib/output/simple_correction_diff.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
Instance Method Summary collapse
- #change(event) ⇒ Object
-
#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 ⇒ SimpleCorrectionDiff
constructor
A new instance of SimpleCorrectionDiff.
-
#match(event) ⇒ Object
This will be called with both lines are the same.
Constructor Details
#initialize ⇒ SimpleCorrectionDiff
Returns a new instance of SimpleCorrectionDiff.
6 7 8 |
# File 'lib/output/simple_correction_diff.rb', line 6 def initialize @content = "" end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
4 5 6 |
# File 'lib/output/simple_correction_diff.rb', line 4 def content @content end |
Instance Method Details
#change(event) ⇒ Object
10 11 12 13 14 |
# File 'lib/output/simple_correction_diff.rb', line 10 def change(event) out = StringSimpleCorrectionDiff.new Diff::LCS.traverse_sequences(event.old_element, event.new_element, out) @content << %Q|<span class="change">#{out.content}#{out.closing}</span><br/></span><br/>\n| end |
#discard_a(event) ⇒ Object
This will be called when there is a line in A that isn’t in B
22 23 24 |
# File 'lib/output/simple_correction_diff.rb', line 22 def discard_a(event) @content << %Q|<span class="only_a"><del>#{event.old_element}</del></span><br/>\n| end |
#discard_b(event) ⇒ Object
This will be called when there is a line in B that isn’t in A
27 28 29 |
# File 'lib/output/simple_correction_diff.rb', line 27 def discard_b(event) @content << %Q|<span class="only_b"><ins>#{event.new_element}</ins></span><br/>\n| end |
#match(event) ⇒ Object
This will be called with both lines are the same
17 18 19 |
# File 'lib/output/simple_correction_diff.rb', line 17 def match(event) @content << %Q|<span class="match">#{event.new_element}</span><br/>\n| end |