module Diff::LCS
def self.callbacks_for(callbacks)
def self.callbacks_for(callbacks) callbacks.new rescue callbacks end
def diff(other, callbacks = nil, &block)
def diff(other, callbacks = nil, &block) Diff::LCS.diff(self, other, callbacks, &block) end
def lcs(other, &block) # :yields: self[i] if there are matched subsequences
O.new('a').hash == O.new('a').hash
O.new('a').eql?(O.new('a')) == true &&
compare identically for key purposes. That is:
the methods +#hash+ and +#eql?+ such that two objects containing identical values
can be used as a key in a Hash. This means that those objects must implement
A note when using objects: Diff::LCS only works properly when each object
lcs = seq1.lcs(seq2)
+self+ and +other+. See Diff::LCS#lcs.
Returns an Array containing the longest common subsequence(s) between
def lcs(other, &block) # :yields: self[i] if there are matched subsequences Diff::LCS.lcs(self, other, &block) end
def patch(patchset)
on +self+ and the +patchset+ will be created. See Diff::LCS#patch. Attempts
Attempts to patch +self+ with the provided +patchset+. A new sequence based
def patch(patchset) Diff::LCS.patch(self, patchset) end
def patch!(patchset)
on +self+ and the +patchset+ will be created. See Diff::LCS#patch. Does no
Attempts to patch +self+ with the provided +patchset+. A new sequence based
def patch!(patchset) Diff::LCS.patch!(self, patchset) end
def patch_me(patchset)
the sequence this is used on supports #replace, the value of +self+ will be
Attempts to patch +self+ with the provided +patchset+, using #patch!. If
def patch_me(patchset) if respond_to? :replace replace(patch!(patchset)) else patch!(patchset) end end
def sdiff(other, callbacks = nil, &block)
Returns the balanced ("side-by-side") difference set between +self+ and
def sdiff(other, callbacks = nil, &block) Diff::LCS.sdiff(self, other, callbacks, &block) end
def traverse_balanced(other, callbacks = nil, &block)
+other+ using the alternate, balanced algorithm. See
Traverses the discovered longest common subsequences between +self+ and
def traverse_balanced(other, callbacks = nil, &block) Diff::LCS.traverse_balanced(self, other, callbacks || Diff::LCS::BalancedCallbacks, &block) end
def traverse_sequences(other, callbacks = nil, &block)
Traverses the discovered longest common subsequences between +self+ and
def traverse_sequences(other, callbacks = nil, &block) Diff::LCS.traverse_sequences(self, other, callbacks || Diff::LCS::SequenceCallbacks, &block) end
def unpatch!(patchset)
based on +self+ and the +patchset+ will be created. See Diff::LCS#unpatch.
Attempts to unpatch +self+ with the provided +patchset+. A new sequence
def unpatch!(patchset) Diff::LCS.unpatch!(self, patchset) end
def unpatch_me(patchset)
If the sequence this is used on supports #replace, the value of +self+ will
Attempts to unpatch +self+ with the provided +patchset+, using #unpatch!.
def unpatch_me(patchset) if respond_to? :replace replace(unpatch!(patchset)) else unpatch!(patchset) end end