Class: Lookout::Diff::Operations
- Includes:
- Enumerable
- Defined in:
- lib/lookout-3.0/diff/operations.rb
Overview
Defined Under Namespace
Classes: Copy, Delete, Insert, Replace
Instance Method Summary collapse
Instance Method Details
# {|operation| ... } ⇒ Object # ⇒ Enumerator<Operation>
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/lookout-3.0/diff/operations.rb', line 19 def each return enum_for(__method__) unless block_given? old = new = 0 matches.each do |match| type = if old < match.old.begin and new < match.new.begin then Replace elsif old < match.old.begin then Delete elsif new < match.new.begin then Insert else Copy end yield type.new(match.old.at(old...match.old.begin), match.new.at(new...match.new.begin)) unless type == Copy yield Copy.new(match.old, match.new) unless match.empty? old, new = match.old.end + 1, match.new.end + 1 end self end |