Module: Diffr

Defined in:
lib/diffr.rb,
lib/diffr/version.rb

Overview

:line=>5, :change=>:add, :string=>“Finally, a brand new line.” ]

Constant Summary collapse

VERSION =
"0.0.1"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#diffsObject

Returns the value of attribute diffs.



31
32
33
# File 'lib/diffr.rb', line 31

def diffs
  @diffs
end

#sequencesObject

Returns the value of attribute sequences.



31
32
33
# File 'lib/diffr.rb', line 31

def sequences
  @sequences
end

Class Method Details

.diffs(old, new) ⇒ Array

Returns an array of hashes that contain metadata about the differences between the two given strings.

Returns:

  • (Array)

    of diffs



38
39
40
41
42
# File 'lib/diffr.rb', line 38

def self.diffs(old, new)
  new, old, @diffs = new.lines.to_a, old.lines.to_a, []
  build_sequences(old, new)
  find_diffs(old, new, old.size, new.size)
end