Class: Uniword::Diff::Semantic::Engine
- Inherits:
-
Object
- Object
- Uniword::Diff::Semantic::Engine
- Defined in:
- lib/uniword/diff/semantic/engine.rb
Overview
Orchestrates element-level diff between two documents.
Currently compares body paragraphs; future comparators
(tables, images, styles) plug in via COMPARATORS.
Instance Method Summary collapse
-
#diff ⇒ Result
Run every registered comparator and aggregate the changes.
-
#initialize(old_doc, new_doc) ⇒ Engine
constructor
A new instance of Engine.
Constructor Details
#initialize(old_doc, new_doc) ⇒ Engine
Returns a new instance of Engine.
12 13 14 15 |
# File 'lib/uniword/diff/semantic/engine.rb', line 12 def initialize(old_doc, new_doc) @old_doc = old_doc @new_doc = new_doc end |
Instance Method Details
#diff ⇒ Result
Run every registered comparator and aggregate the changes.
20 21 22 23 24 25 26 27 |
# File 'lib/uniword/diff/semantic/engine.rb', line 20 def diff result = Result.new ParagraphComparator.each_change(@old_doc.paragraphs, @new_doc.paragraphs) do |change| result.add(change) end result end |