Class: Lookout::Diff::Operation
- 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”.
Direct Known Subclasses
Lookout::Diff::Operations::Copy, Lookout::Diff::Operations::Delete, Lookout::Diff::Operations::Insert, Lookout::Diff::Operations::Replace
Instance Method Summary collapse
-
#<<(context) ⇒ Object
Folds from the end of the receiver, leaving CONTEXT elements.
-
#>>(context) ⇒ Object
Folds from the beginning of the receiver, leaving CONTEXT elements.
-
#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.
-
#foldable?(context) ⇒ Boolean
True if the operation is uninteresting to the actual “diff” and can be meaningfully folded, leaving CONTEXT elements.
-
#parity? ⇒ Boolean
True if the receiver represents parity.
Instance Method Details
#<<(context) ⇒ Object
Logically, the receiver should be #foldable? inside CONTEXT, but this isn’t enforced.
Folds from the end of the receiver, leaving CONTEXT elements.
28 |
# File 'lib/lookout-3.0/diff/operation.rb', line 28 def <<(context) self end |
#>>(context) ⇒ Object
Logically, the receiver should be #foldable? inside CONTEXT, but this isn’t enforced.
Folds from the beginning of the receiver, leaving CONTEXT elements.
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.
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.
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.
32 |
# File 'lib/lookout-3.0/diff/operation.rb', line 32 def parity?; false end |