vendor/gems/diff-lcs-1.1.2/lib/diff/lcs.rb
# Diff::LCS.diff computes the smallest set of additions and deletions
# necessary to turn the first sequence into the second, and returns a
# description of these changes.
# 
# See Diff::LCS::DiffCallbacks for the default behaviour. An alternate
# behaviour may be implemented with Diff::LCS::ContextDiffCallbacks.
# If a Class argument is provided for +callbacks+, #diff will attempt
# to initialise it. If the +callbacks+ object (possibly initialised)
# responds to #finish, it will be called.
:LCS.diff computes the smallest set of additions and deletions
necessary to turn the first sequence into the second, and returns a
description of these changes.

See Diff::LCS::DiffCallbacks for the default behaviour. An alternate
behaviour may be implemented with Diff::LCS::ContextDiffCallbacks.
If a Class argument is provided for +callbacks+, #diff will attempt
to initialise it. If the +callbacks+ object (possibly initialised)
responds to #finish, it will be called.
: LCS . diff computes the smallest set of additions and deletions necessary to turn the first sequence into the second and returns a description of these changes . See Diff :: LCS :: DiffCallbacks for the default behaviour . An alternate behaviour may be implemented with Diff :: LCS :: ContextDiffCallbacks . If a Class argument is provided for + callbacks + #diff will attempt to initialise it . If the + callbacks + object ( possibly initialised ) responds to #finish it will be called .
def diff(seq1, seq2, callbacks = nil, &block) 
      callbacks ||= Diff::LCS::DiffCallbacks
      if callbacks.kind_of?(Class)
        cb = callbacks.new rescue callbacks
        callbacks = cb
      end
      traverse_sequences(seq1, seq2, callbacks)
      callbacks.finish if callbacks.respond_to?(:finish)
      if block_given?
        res = callbacks.diffs.map do |hunk|
          if hunk.kind_of?(Array)
            hunk = hunk.map { |block| yield block }
          else
            yield hunk
          end
        end
        res
      else
        callbacks.diffs
      end
    end
def diff ( seq1 , seq2 , callbacks = nil , & block ) callbacks ||= Diff :: LCS :: DiffCallbacks if callbacks . kind_of? ( Class ) cb = callbacks . new rescue callbacks callbacks = cb end traverse_sequences ( seq1 , seq2 , callbacks ) callbacks . finish if callbacks . respond_to? ( :finish ) if block_given? res = callbacks . diffs . map do | hunk | if hunk . kind_of? ( Array ) hunk = hunk . map { | block | yield block } else yield hunk end end res else callbacks . diffs end end
Diff::LCS.diff computes the smallest set of additions and deletions
necessary to turn the first sequence into the second, and returns a
description of these changes.
Diff :: LCS . diff computes the smallest set of additions and deletions necessary to turn the first sequence into the second and returns a description of these changes .
# :yields diff changes:
seq1
seq2
callbacks
block