Class: Uniword::Diff::DocumentDiffer
- Inherits:
-
Object
- Object
- Uniword::Diff::DocumentDiffer
- Defined in:
- lib/uniword/diff/document_differ.rb
Overview
Compares two DocumentRoot instances and produces a DiffResult.
Uses LCS (longest common subsequence) alignment for paragraphs to detect added, removed, and modified paragraphs. Optionally compares formatting, structure, metadata, and styles.
Instance Method Summary collapse
-
#diff ⇒ DiffResult
Perform the diff and return a DiffResult.
-
#initialize(old_doc, new_doc, options: {}) ⇒ DocumentDiffer
constructor
Initialize with two documents and options.
Constructor Details
#initialize(old_doc, new_doc, options: {}) ⇒ DocumentDiffer
Initialize with two documents and options.
27 28 29 30 31 |
# File 'lib/uniword/diff/document_differ.rb', line 27 def initialize(old_doc, new_doc, options: {}) @old_doc = old_doc @new_doc = new_doc @options = end |
Instance Method Details
#diff ⇒ DiffResult
Perform the diff and return a DiffResult.
36 37 38 39 40 41 42 43 44 |
# File 'lib/uniword/diff/document_differ.rb', line 36 def diff DiffResult.new( text_changes: diff_text, format_changes: text_only? ? [] : diff_formatting, structure_changes: diff_structure, metadata_changes: , style_changes: diff_styles, ) end |