Class: Lookout::Diff::Groups
- Includes:
- Enumerable
- Defined in:
- lib/lookout-3.0/diff/groups.rb
Overview
Sequence of Operations bundled together into Groups that can then be used to show the subsequences that differ, folding away the subsequences that are the same, only keeping some context around the folding points.
Instance Method Summary collapse
Instance Method Details
# {|group| ... } ⇒ Object # ⇒ Enumerator<Group>
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/lookout-3.0/diff/groups.rb', line 21 def each return enum_for(__method__) unless block_given? saved = nil group = Lookout::Diff::Group.new operations.each do |operation| if saved yield saved saved = nil end if group.empty? operation = operation >> context group << operation elsif operation.foldable? context saved = group << (operation << context) group = Lookout::Diff::Group.new(operation >> context) else group << operation end end if saved yield saved elsif not group.empty? yield group.fold(context) end self end |