Class: Lookout::Diff::Operations::Copy
- Inherits:
-
Lookout::Diff::Operation
- Object
- Lookout::Diff::Operation
- Lookout::Diff::Operations::Copy
- Defined in:
- lib/lookout-3.0/diff/operations/copy.rb
Overview
Slice that should be copied from the old sequence.
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.
- #foldable?(context) ⇒ Boolean
-
#parity? ⇒ Boolean
True if #old ‘#==` #new.
Methods inherited from Lookout::Diff::Operation
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.
18 19 20 21 |
# File 'lib/lookout-3.0/diff/operations/copy.rb', line 18 def <<(context) self.class.new(old.end_at([old.end, old.begin + context - 1].min), new.end_at([new.end, new.begin + context - 1].min)) 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.
12 13 14 15 |
# File 'lib/lookout-3.0/diff/operations/copy.rb', line 12 def >>(context) self.class.new(old.begin_at([old.begin, old.end - context + 1].max), new.begin_at([new.begin, new.end - context + 1].max)) end |
#foldable?(context) ⇒ Boolean
9 |
# File 'lib/lookout-3.0/diff/operations/copy.rb', line 9 def foldable?(context) old.size > context * 2 end |
#parity? ⇒ Boolean
Returns True if #old ‘#==` #new.
24 |
# File 'lib/lookout-3.0/diff/operations/copy.rb', line 24 def parity?; old == new end |