Class: Lookout::Diff::Algorithms::Difflib::Position
- Defined in:
- lib/lookout-3.0/diff/algorithms/difflib/position.rb
Overview
Keeps track of a position into the two sequences currently being “diffed” of the difflib algorithm and generates matches and new positions based on this position.
Defined Under Namespace
Classes: New
Class Method Summary collapse
Instance Method Summary collapse
- #begin_after(match) ⇒ Object
- #begin_before?(match) ⇒ Boolean
- #end_after?(match) ⇒ Boolean
- #end_before(match) ⇒ Object
- #inspect ⇒ Object
- #match ⇒ Object
Class Method Details
permalink .origin(old, new) ⇒ Object
[View source]
12 13 14 15 16 17 |
# File 'lib/lookout-3.0/diff/algorithms/difflib/position.rb', line 12 def origin(old, new) new = New.new(new) new(Lookout::Diff::Slice.new(old), new, block_given? ? new.indexes.reduce({}){ |j, (k, _)| j[k] = yield(k); j } : {}) end |
Instance Method Details
permalink #begin_after(match) ⇒ Object
[View source]
23 |
# File 'lib/lookout-3.0/diff/algorithms/difflib/position.rb', line 23 def begin_after(match) self.class.new(old.begin_after(match.old), new.begin_after(match.new), junk) end |
permalink #begin_before?(match) ⇒ Boolean
21 |
# File 'lib/lookout-3.0/diff/algorithms/difflib/position.rb', line 21 def begin_before?(match) old.begin_before? match.old and new.begin_before? match.new end |
permalink #end_after?(match) ⇒ Boolean
22 |
# File 'lib/lookout-3.0/diff/algorithms/difflib/position.rb', line 22 def end_after?(match) old.end_after? match.old and new.end_after? match.new end |
permalink #end_before(match) ⇒ Object
[View source]
24 |
# File 'lib/lookout-3.0/diff/algorithms/difflib/position.rb', line 24 def end_before(match) self.class.new(old.end_before(match.old), new.end_before(match.new), junk) end |
permalink #inspect ⇒ Object
[View source]
25 |
# File 'lib/lookout-3.0/diff/algorithms/difflib/position.rb', line 25 def inspect; '#<%s %p,%p>' % [self.class, old, new] end |
permalink #match ⇒ Object
[View source]
20 |
# File 'lib/lookout-3.0/diff/algorithms/difflib/position.rb', line 20 def match; junk.empty? ? leftmost_longest : ((leftmost_longest, false), true) end |