Class: Lookout::Difference::String

Inherits:
Object show all
Defined in:
lib/lookout-3.0/difference/string.rb

Overview

Difference reports between Strings.

Instance Attribute Summary

Attributes inherited from Object

#actual, #expected

Instance Method Summary collapse

Methods inherited from Object

#==, #hash, #initialize, #message, #to_s

Constructor Details

This class inherits a constructor from Lookout::Difference::Object

Instance Method Details

#diffDiff::Formats::Unified, ...

Returns A unified “diff” if Object#actual or Object#expected include a newline, an inline “diff” otherwise, or super if Object#actual isn’t a String.

Returns:



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/lookout-3.0/difference/string.rb', line 8

def diff
  return super unless String === actual
  (actual.include? "\n" or expected.include? "\n") ?
    Lookout::Diff::Formats::Unified.
      new(Lookout::Diff::Groups.
            new(Lookout::Diff::Operations.
                  new(Lookout::Diff::Algorithms::Difflib.
                        new(actual.split("\n"), expected.split("\n"))))) :
    Lookout::Diff::Formats::Inline.
      new(Lookout::Diff::Operations.
            new(Lookout::Diff::Algorithms::Difflib.
                  new(actual, expected)))
end