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:



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

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

Instance Attribute Details

#diffsObject (readonly)

Returns the difference set collected during the diff process.



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

def diffs
  @diffs
end

Instance Method Details

#change(event) ⇒ Object



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

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



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

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

#discard_b(event) ⇒ Object



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

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

#match(event) ⇒ Object



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

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