Class: Lookout::Diff::Formats::Inline

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/lookout-3.0/diff/formats/inline.rb

Overview

Formats Operations inline in a String. Additions are shown as ‘+…+` and deletions as `[-…-]`. Replacements are shown as a deletion followed by an insertion.

This format is used by Lookout::Difference::String for single-line Strings.

This format is inspired by the plain word “diff” format used by [Git](git-scm.com/). That format was surely inspired by something before it, but it’s where I first saw it, so that’s what I’m referencing.

Defined Under Namespace

Classes: ToS

Instance Method Summary collapse

Instance Method Details

# {|string| ... } ⇒ Object #Enumerator<String>

Overloads:

  • # {|string| ... } ⇒ Object

    Enumerates the formatted operations.

    Yield Parameters:

  • #Enumerator<String>

    Returns An Enumerator over the formatted operations.

    Returns:

    • (Enumerator<String>)

      An Enumerator over the formatted operations

Yields:



24
25
26
27
28
# File 'lib/lookout-3.0/diff/formats/inline.rb', line 24

def each
  return enum_for(__method__) unless block_given?
  yield to_s
  self
end

#to_sObject

Returns The concatenation of the formatted operations.

Returns:

  • The concatenation of the formatted operations



31
# File 'lib/lookout-3.0/diff/formats/inline.rb', line 31

def to_s; @to_s ||= ToS.new(operations).to_s end