Class: MailDiff::Line
- Inherits:
-
Object
- Object
- MailDiff::Line
- Defined in:
- lib/mail_diff/line.rb
Overview
Represent a single line of the diff.
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
:nodoc:.
-
#diff ⇒ Object
readonly
:nodoc:.
-
#left_number ⇒ Object
Returns the value of attribute left_number.
-
#right_number ⇒ Object
Returns the value of attribute right_number.
Instance Method Summary collapse
- #added? ⇒ Boolean
- #deleted? ⇒ Boolean
-
#format ⇒ Object
Prepare Line contents for injection into HTML structure.
-
#ignore? ⇒ Boolean
Unified Diff sometimes emit a special line at the end of the file that we should not display in the output.
-
#initialize(diff, content) ⇒ Line
constructor
A new instance of Line.
- #not_modified? ⇒ Boolean
-
#status ⇒ Object
Return status of the Line.
-
#to_html ⇒ Object
Generate HTML presentation for a Line.
Constructor Details
#initialize(diff, content) ⇒ Line
Returns a new instance of Line.
9 10 11 12 |
# File 'lib/mail_diff/line.rb', line 9 def initialize(diff, content) @diff = diff @content = content end |
Instance Attribute Details
#content ⇒ Object (readonly)
:nodoc:
6 7 8 |
# File 'lib/mail_diff/line.rb', line 6 def content @content end |
#diff ⇒ Object (readonly)
:nodoc:
6 7 8 |
# File 'lib/mail_diff/line.rb', line 6 def diff @diff end |
#left_number ⇒ Object
Returns the value of attribute left_number.
7 8 9 |
# File 'lib/mail_diff/line.rb', line 7 def left_number @left_number end |
#right_number ⇒ Object
Returns the value of attribute right_number.
7 8 9 |
# File 'lib/mail_diff/line.rb', line 7 def right_number @right_number end |
Instance Method Details
#added? ⇒ Boolean
45 46 47 |
# File 'lib/mail_diff/line.rb', line 45 def added? status == :added end |
#deleted? ⇒ Boolean
49 50 51 |
# File 'lib/mail_diff/line.rb', line 49 def deleted? status == :deleted end |
#format ⇒ Object
Prepare Line contents for injection into HTML structure. Currently used for replacing Tab symbols with spaces. Return a string.
22 23 24 |
# File 'lib/mail_diff/line.rb', line 22 def format content.gsub("\t", ' ') end |
#ignore? ⇒ Boolean
Unified Diff sometimes emit a special line at the end of the file that we should not display in the output. Return true or false.
29 30 31 |
# File 'lib/mail_diff/line.rb', line 29 def ignore? content =~ /\\ No newline at end of file/ end |
#not_modified? ⇒ Boolean
53 54 55 |
# File 'lib/mail_diff/line.rb', line 53 def not_modified? status == :not_modified end |
#status ⇒ Object
Return status of the Line. Can be :added, :deleted or :not_modified.
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/mail_diff/line.rb', line 34 def status case content when /^\+/ :added when /^\-/ :deleted else :not_modified end end |
#to_html ⇒ Object
Generate HTML presentation for a Line. Return a string.
15 16 17 |
# File 'lib/mail_diff/line.rb', line 15 def to_html generator.generate end |