Diff produces colorized differences of two string or objects.
Rotation of colors for diff output.
Highlights the differnce between two strings.
This class method is equivalent to calling:
ANSI::Diff.new(object1, object2).to_a
# File lib/ansi/diff.rb, line 15 def self.diff(object1, object2, options={}) new(object1, object2, options={}).to_a end
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.)
# File lib/ansi/diff.rb, line 33 def initialize(object1, object2, options={}) @object1 = convert(object1) @object2 = convert(object2) @diff1, @diff2 = diff_string(@object1, @object2) end
Returns the first object’s difference string.
# File lib/ansi/diff.rb, line 41 def diff1 @diff1 end
Returns the second object’s difference string.
# File lib/ansi/diff.rb, line 46 def diff2 @diff2 end
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.
# File lib/ansi/diff.rb, line 67 def join(separator=$/) "#{@diff1}#{separator}#{@diff2}" end
Generated with the Darkfish Rdoc Generator 2.