Class: Uniword::Diff::Semantic::Engine

Inherits:
Object
  • Object
show all
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

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

#diffResult

Run every registered comparator and aggregate the changes.

Returns:



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