vendor/gems/diff-lcs-1.1.2/lib/diff/lcs.rb
def sdiff(seq1, seq2, callbacks = nil, &block) #:yields diff changes:
      callbacks ||= Diff::LCS::SDiffCallbacks
      if callbacks.kind_of?(Class)
        cb = callbacks.new rescue callbacks
        callbacks = cb
      end
      traverse_balanced(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.sdiff computes all necessary components to show two sequences
# and their minimized differences side by side, just like the Unix
# utility <em>sdiff</em> does:
#
#     old        <     -
#     same             same
#     before     |     after
#     -          >     new
#
# See Diff::LCS::SDiffCallbacks 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.sdiff computes all necessary components to show two sequences
and their minimized differences side by side, just like the Unix
utility sdiff does.

old        <
same             same
before     |     after
>     new

See Diff::LCS::SDiffCallbacks 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 . sdiff computes all necessary components to show two sequences and their minimized differences side by side just like the Unix utility sdiff does . old < same same before | after > new See Diff :: LCS :: SDiffCallbacks 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 sdiff(seq1, seq2, callbacks = nil, &block) 
      callbacks ||= Diff::LCS::SDiffCallbacks
      if callbacks.kind_of?(Class)
        cb = callbacks.new rescue callbacks
        callbacks = cb
      end
      traverse_balanced(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 sdiff ( seq1 , seq2 , callbacks = nil , & block ) callbacks ||= Diff :: LCS :: SDiffCallbacks if callbacks . kind_of? ( Class ) cb = callbacks . new rescue callbacks callbacks = cb end traverse_balanced ( 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.sdiff computes all necessary components to show two sequences
and their minimized differences side by side, just like the Unix
utility <em>sdiff</em> does:
Diff :: LCS . sdiff computes all necessary components to show two sequences and their minimized differences side by side just like the Unix utility <em > sdiff< / em > does :
#:yields diff changes:
seq1
seq2
callbacks
block