Class: ANSI::Diff

Inherits:
Object
  • Object
show all
Defined in:
lib/ansi/diff.rb

Overview

Diff can produced a colorized difference of two string or objects.

IMPORTANT! This class is still a very much a work in progress.

Instance Method Summary collapse

Constructor Details

#initialize(object1, object2, options = {}) ⇒ Diff

Returns a new instance of Diff.



11
12
13
14
15
16
# File 'lib/ansi/diff.rb', line 11

def initialize(object1, object2, options={})
  @object1 = convert(object1)
  @object2 = convert(object2)

  @diff1, @diff2 = diff_string(@object1, @object2)
end

Instance Method Details

#diff1Object



19
20
21
# File 'lib/ansi/diff.rb', line 19

def diff1
  @diff1
end

#diff2Object



24
25
26
# File 'lib/ansi/diff.rb', line 24

def diff2
  @diff2
end

#to_sObject



29
30
31
# File 'lib/ansi/diff.rb', line 29

def to_s
  "#{@diff1}\n#{@diff2}"
end