Class: Differ

Inherits:
Struct
  • Object
show all
Defined in:
lib/differ.rb,
lib/differ.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#targetObject

Returns the value of attribute target

Returns:

  • (Object)

    the current value of target



20
21
22
# File 'lib/differ.rb', line 20

def target
  @target
end

Instance Method Details

#diff(old_elems, new_elems) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/differ.rb', line 23

def diff(old_elems, new_elems)
  sdiffs = old_elems.sdiff(new_elems)
  
  last_action = nil
  sdiffs.each do |sdiff|
    if chunk_break_needed(last_action, sdiff.action)
      target.start_new_chunk(sdiff.action)
    end
    last_action = sdiff.action
    
    target.store_diff(sdiff)
  end

  target.get_result
end