Class: Lookout::Diff::Operations
- Includes:
- Enumerable
- Defined in:
- lib/lookout/diff/operations.rb
Defined Under Namespace
Classes: Delete, Equal, Insert, Replace
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(matches) ⇒ Operations
constructor
A new instance of Operations.
Constructor Details
#initialize(matches) ⇒ Operations
Returns a new instance of Operations.
11 12 13 |
# File 'lib/lookout/diff/operations.rb', line 11 def initialize(matches) @matches = matches end |
Instance Method Details
#each ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/lookout/diff/operations.rb', line 15 def each from = to = 0 @matches.each do |match| type = typeify(from, to, match) yield type.new(match.from.at(from...match.from.begin), match.to.at(to...match.to.begin)) unless type == Equal yield Equal.new(match.from, match.to) unless match.empty? from, to = match.from.end + 1, match.to.end + 1 end self end |