Class: Palmister::SimpleHtmlDiff
- Inherits:
-
Object
- Object
- Palmister::SimpleHtmlDiff
- Defined in:
- lib/palmister/simple_html_diff.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#new_line ⇒ Object
Returns the value of attribute new_line.
-
#old_line ⇒ Object
Returns the value of attribute old_line.
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 ⇒ SimpleHtmlDiff
constructor
A new instance of SimpleHtmlDiff.
-
#match(event) ⇒ Object
This will be called with both lines are the same.
Constructor Details
#initialize ⇒ SimpleHtmlDiff
Returns a new instance of SimpleHtmlDiff.
7 8 9 10 11 |
# File 'lib/palmister/simple_html_diff.rb', line 7 def initialize @content = "" @old_line = 1 @new_line = 1 end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content
3 4 5 |
# File 'lib/palmister/simple_html_diff.rb', line 3 def content @content end |
#new_line ⇒ Object
Returns the value of attribute new_line
5 6 7 |
# File 'lib/palmister/simple_html_diff.rb', line 5 def new_line @new_line end |
#old_line ⇒ Object
Returns the value of attribute old_line
4 5 6 |
# File 'lib/palmister/simple_html_diff.rb', line 4 def old_line @old_line end |
Instance Method Details
#change(event) ⇒ Object
13 14 15 16 17 |
# File 'lib/palmister/simple_html_diff.rb', line 13 def change(event) @content << %Q|<tr><td>#{old_line}. </td><td><pre class="only_a">#{event.old_element}</pre></td><td><pre class="only_b">#{event.new_element}</pre></td><td>#{new_line}. </td></tr>\n| @old_line += 1 @new_line += 1 end |
#discard_a(event) ⇒ Object
This will be called when there is a line in A that isn't in B
27 28 29 30 |
# File 'lib/palmister/simple_html_diff.rb', line 27 def discard_a(event) @content << %Q|<tr><td>#{old_line}. </td><td><pre class="only_a">#{event.old_element}</pre></td><td></td><td></td></tr>\n| @old_line += 1 end |
#discard_b(event) ⇒ Object
This will be called when there is a line in B that isn't in A
33 34 35 36 |
# File 'lib/palmister/simple_html_diff.rb', line 33 def discard_b(event) @content << %Q|<tr><td></td><td></td><td><pre class="only_b">#{event.new_element}</pre></td><td>#{new_line}. </td></tr>\n| @new_line += 1 end |
#match(event) ⇒ Object
This will be called with both lines are the same
20 21 22 23 24 |
# File 'lib/palmister/simple_html_diff.rb', line 20 def match(event) @content << %Q|<tr><td>#{old_line}. </td><td colspan="2"><pre class="match">#{event.old_element}</pre></td><td>#{new_line}. </td></tr>\n| @old_line += 1 @new_line += 1 end |