Class: Lookout::Diff::Operation

Inherits:
Object
  • Object
show all
Defined in:
lib/lookout-3.0/diff/operation.rb

Overview

Base class for operations describing the changes to perform to get from the old version of a sequence to the new in a “diff”.

Instance Method Summary collapse

Instance Method Details

#<<(context) ⇒ Object

Note:

Logically, the receiver should be #foldable? inside CONTEXT, but this isn’t enforced.

Folds from the end of the receiver, leaving CONTEXT elements.

Parameters:

  • context (Integer)


28
# File 'lib/lookout-3.0/diff/operation.rb', line 28

def <<(context) self end

#>>(context) ⇒ Object

Note:

Logically, the receiver should be #foldable? inside CONTEXT, but this isn’t enforced.

Folds from the beginning of the receiver, leaving CONTEXT elements.

Parameters:

  • context (Integer)


22
# File 'lib/lookout-3.0/diff/operation.rb', line 22

def >>(context) self end

#apply(object) ⇒ Object

Implements a double dispatch for enumerating operations, where OBJECT is sent the last part of the receiver’s class’ name with the receiver as the lone argument.

Returns:

  • The result of OBJECT#name(self)



38
39
40
# File 'lib/lookout-3.0/diff/operation.rb', line 38

def apply(object)
  object.send(@apply ||= self.class.name.split('::').last.downcase.to_sym, self)
end

#foldable?(context) ⇒ Boolean

Returns True if the operation is uninteresting to the actual “diff” and can be meaningfully folded, leaving CONTEXT elements.

Parameters:

  • context (Integer)

Returns:

  • (Boolean)

    True if the operation is uninteresting to the actual “diff” and can be meaningfully folded, leaving CONTEXT elements

See Also:



16
# File 'lib/lookout-3.0/diff/operation.rb', line 16

def foldable?(context) false end

#parity?Boolean

Returns True if the receiver represents parity.

Returns:

  • (Boolean)

    True if the receiver represents parity

See Also:



32
# File 'lib/lookout-3.0/diff/operation.rb', line 32

def parity?; false end