disu.se

DifflibClass

Namespace

Lookout::Diff::Algorithms

Ancestors
  1. Enumerable

  2. Value

  3. Object

The difflib algorithm is based on the algorithm employed by the difflib library for Python, which is, in turn, based on an algorithm by Ratcliff and Obershelp, see http://docs.python.org/library/difflib.html.

It’s implemented as an Enumerable over the Matches between two sequences. There are very few requirements on these sequences (see #initialize), which makes this implementation useful for a wide class of objects.

Constructor

initialize(old#each, #[], new#each, #[]){ |elementObject|Boolean … }?#

Initializes the algorithm to generate matches between the old and new versions of the indexable sequences. The sequences must be indexable by ::Ranges and Integers with the semantics that, for example, ::Arrays have, and their elements must also respond to #hash and #==.

A block may be given to determine what elements in new are to be ignored. This can be used to, for example, ignore whitespace differences.

Instance Methods

each{ |matchMatch| … }self#

Enumerates the matches between the two sequences. There’ll always be at least one match yielded, the empty one at the end of the sequences.

eachEnumerator<Match>#

Returns an Enumerator over the matches between the two sequences.