Class ANSI::Diff
In: lib/ansi/diff.rb
Parent: Object

Diff produces colorized differences of two string or objects.

Methods

diff   diff1   diff2   join   new   to_a   to_s  

Constants

COLORS = [:red, :yellow, :magenta]   Rotation of colors for diff output.

Public Class methods

Highlights the differnce between two strings.

This class method is equivalent to calling:

  ANSI::Diff.new(object1, object2).to_a

Setup new Diff object. If the objects given are not Strings and do not have `to_str` defined to coerce them to such, then their `inspect` methods are used to convert them to strings for comparison.

@param [Object] object1

  First object to compare.

@param [Object] object2

  Second object to compare.

@param [Hash] options

  Options for contoller the way difference is shown. (Not yet used.)

Public Instance methods

Returns the first object‘s difference string.

Returns the second object‘s difference string.

Returns both first and second difference strings separated by a the given `separator`. The default is `$/`, the record separator.

@param [String] separator

  The string to use as the separtor between the difference strings.

@return [String] Joined difference strings.

Returns the first and second difference strings in an array.

@return [Array] Both difference strings.

Returns both first and second difference strings separated by a new line character.

@todo Should we use `$/` record separator instead?

@return [String] Joined difference strings.

[Validate]