Class: Lookout::Diff::Formats::Unified::Group
- Defined in:
- lib/lookout/diff/formats/unified.rb
Instance Method Summary collapse
- #delete(operation) ⇒ Object
- #equal(operation) ⇒ Object
-
#initialize(group) ⇒ Group
constructor
A new instance of Group.
- #insert(operation) ⇒ Object
- #replace(operation) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(group) ⇒ Group
Returns a new instance of Group.
21 22 23 |
# File 'lib/lookout/diff/formats/unified.rb', line 21 def initialize(group) @group = group end |
Instance Method Details
#delete(operation) ⇒ Object
25 26 27 |
# File 'lib/lookout/diff/formats/unified.rb', line 25 def delete(operation) mark('-', operation.from) end |
#equal(operation) ⇒ Object
29 30 31 |
# File 'lib/lookout/diff/formats/unified.rb', line 29 def equal(operation) mark(' ', operation.from) end |
#insert(operation) ⇒ Object
33 34 35 |
# File 'lib/lookout/diff/formats/unified.rb', line 33 def insert(operation) mark('+', operation.to) end |
#replace(operation) ⇒ Object
37 38 39 |
# File 'lib/lookout/diff/formats/unified.rb', line 37 def replace(operation) delete(operation).concat(insert(operation)) end |
#to_s ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/lookout/diff/formats/unified.rb', line 41 def to_s lines = ['@@ -%d,%d +%d,%d @@' % [@group.from.begin + 1, @group.from.size, @group.to.begin + 1, @group.to.size]] @group.each do |operation| lines.concat operation.apply(self) end lines.join("\n") end |