Class: MailDiff::Chunk

Inherits:
Object
  • Object
show all
Defined in:
lib/mail_diff/chunk.rb

Overview

Represent a single piece of a diff.

Instance Attribute Summary collapse

Instance Method Summary collapse

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, meta_info, content)
  @diff = diff
  @meta_info = meta_info
  @content = content
end

Instance Attribute Details

#contentObject (readonly)

:nodoc:



5
6
7
# File 'lib/mail_diff/chunk.rb', line 5

def content
  @content
end

#diffObject (readonly)

:nodoc:



5
6
7
# File 'lib/mail_diff/chunk.rb', line 5

def diff
  @diff
end

#linesObject (readonly)

:nodoc:



5
6
7
# File 'lib/mail_diff/chunk.rb', line 5

def lines
  @lines
end

#meta_infoObject (readonly)

:nodoc:



5
6
7
# File 'lib/mail_diff/chunk.rb', line 5

def meta_info
  @meta_info
end

Instance Method Details

#line_numbersObject

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, meta_info)
end

#to_htmlObject

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