Class: MailDiff::Chunk
- Inherits:
-
Object
- Object
- MailDiff::Chunk
- Defined in:
- lib/mail_diff/chunk.rb
Overview
Represent a single piece of a diff.
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
:nodoc:.
-
#diff ⇒ Object
readonly
:nodoc:.
-
#lines ⇒ Object
readonly
:nodoc:.
-
#meta_info ⇒ Object
readonly
:nodoc:.
Instance Method Summary collapse
-
#initialize(diff, meta_info, content) ⇒ Chunk
constructor
A new instance of Chunk.
-
#line_numbers ⇒ Object
Return LineNumbers object that represents two columns of numbers that will be displayed on the left of the HTML presentation.
-
#to_html ⇒ Object
Generate HTML presentation for a Chunk.
Constructor Details
#initialize(diff, meta_info, content) ⇒ Chunk
Returns a new instance of Chunk.
7 8 9 10 11 |
# File 'lib/mail_diff/chunk.rb', line 7 def initialize(diff, , content) @diff = diff @meta_info = @content = content end |
Instance Attribute Details
#content ⇒ Object (readonly)
:nodoc:
5 6 7 |
# File 'lib/mail_diff/chunk.rb', line 5 def content @content end |
#diff ⇒ Object (readonly)
:nodoc:
5 6 7 |
# File 'lib/mail_diff/chunk.rb', line 5 def diff @diff end |
#lines ⇒ Object (readonly)
:nodoc:
5 6 7 |
# File 'lib/mail_diff/chunk.rb', line 5 def lines @lines end |
#meta_info ⇒ Object (readonly)
:nodoc:
5 6 7 |
# File 'lib/mail_diff/chunk.rb', line 5 def @meta_info end |
Instance Method Details
#line_numbers ⇒ Object
Return LineNumbers object that represents two columns of numbers that will be displayed on the left of the HTML presentation.
IMPORTANT! Before calling this method it’s essential to call “find_lines!” first, otherwise the array will be empty.
25 26 27 |
# File 'lib/mail_diff/chunk.rb', line 25 def line_numbers @_line_numbers ||= MailDiff::LineNumbers.new(diff, ) end |
#to_html ⇒ Object
Generate HTML presentation for a Chunk. Return a string.
14 15 16 17 18 |
# File 'lib/mail_diff/chunk.rb', line 14 def to_html # We have to find lines before we can call line numbers methods. find_lines! generator.generate end |