Class: Palmister::SimpleCorrectionDiff
- Inherits:
-
Object
- Object
- Palmister::SimpleCorrectionDiff
- Includes:
- ERB::Util
- Defined in:
- lib/palmister/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.
8 9 10 |
# File 'lib/palmister/simple_correction_diff.rb', line 8 def initialize @content = "" end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content
6 7 8 |
# File 'lib/palmister/simple_correction_diff.rb', line 6 def content @content end |
Instance Method Details
#change(event) ⇒ Object
12 13 14 15 16 |
# File 'lib/palmister/simple_correction_diff.rb', line 12 def change(event) out = Palmister::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
24 25 26 |
# File 'lib/palmister/simple_correction_diff.rb', line 24 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
29 30 31 |
# File 'lib/palmister/simple_correction_diff.rb', line 29 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
19 20 21 |
# File 'lib/palmister/simple_correction_diff.rb', line 19 def match(event) @content << %Q|<span class="match">#{event.new_element}</span><br/>\n| end |