Class: SimpleCorrectionDiff

Inherits:
Object
  • Object
show all
Includes:
ERB::Util
Defined in:
lib/output/simple_correction_diff.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSimpleCorrectionDiff

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

#contentObject

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