Class: Diff::LCS::NoReplaceDiffCallbacks

Inherits:
Object
  • Object
show all
Defined in:
lib/callbacks.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ NoReplaceDiffCallbacks

:yields self:

Yields:

  • (_self)

Yield Parameters:



9
10
11
12
# File 'lib/callbacks.rb', line 9

def initialize
  @diffs = []
  yield self if block_given?
end

Instance Attribute Details

#diffsObject (readonly)

Returns the difference set collected during the diff process.



6
7
8
# File 'lib/callbacks.rb', line 6

def diffs
  @diffs
end

Instance Method Details

#change(event) ⇒ Object



26
27
28
29
30
# File 'lib/callbacks.rb', line 26

def change(event)
  discard_a(Diff::LCS::ContextChange.new("<", event.old_position, event.old_element, nil, nil))
  discard_b(Diff::LCS::ContextChange.new(">", nil, nil, event.new_position, event.new_element))
  # @diffs << Diff::LCS::ContextChange.simplify(event)

end

#discard_a(event) ⇒ Object



18
19
20
# File 'lib/callbacks.rb', line 18

def discard_a(event)
  @diffs << Diff::LCS::ContextChange.simplify(event)
end

#discard_b(event) ⇒ Object



22
23
24
# File 'lib/callbacks.rb', line 22

def discard_b(event)
  @diffs << Diff::LCS::ContextChange.simplify(event)
end

#match(event) ⇒ Object



14
15
16
# File 'lib/callbacks.rb', line 14

def match(event)
  @diffs << Diff::LCS::ContextChange.simplify(event)
end