Class: MailDiff::Diff
- Inherits:
-
Object
- Object
- MailDiff::Diff
- Defined in:
- lib/mail_diff/diff.rb
Overview
Main class to interact with. In fact this is the only class you should interact with when using the library.
Usage example
mail_diff = MailDiff::Diff.new(udiff)
mail_diff.to_html
Keep in mind that Diff will automatically escape all HTML tags from the intput string so that it doesn’t interfere with the output.
Constant Summary collapse
- CHUNK_REGEXP =
/@@ .+ @@\n/
Instance Attribute Summary collapse
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#chunks ⇒ Object
Return an array of Chunk objects that Diff found in the input.
-
#initialize(unified_diff, options = {}) ⇒ Diff
constructor
Create new Diff object.
-
#to_html ⇒ Object
Generate HTML presentation.
Constructor Details
#initialize(unified_diff, options = {}) ⇒ Diff
Create new Diff object. Accept a String in unified diff format and options hash.
21 22 23 24 |
# File 'lib/mail_diff/diff.rb', line 21 def initialize(unified_diff, ={}) @input = escape_html(unified_diff) @options = end |
Instance Attribute Details
#input ⇒ Object (readonly)
Returns the value of attribute input.
17 18 19 |
# File 'lib/mail_diff/diff.rb', line 17 def input @input end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
17 18 19 |
# File 'lib/mail_diff/diff.rb', line 17 def @options end |
Instance Method Details
#chunks ⇒ Object
Return an array of Chunk objects that Diff found in the input.
32 33 34 |
# File 'lib/mail_diff/diff.rb', line 32 def chunks @_chunks ||= find_chunks(input) end |
#to_html ⇒ Object
Generate HTML presentation. Return a string.
27 28 29 |
# File 'lib/mail_diff/diff.rb', line 27 def to_html generator.generate end |