Class: Lookout::Diff::Formats::Inline::ToS
- Defined in:
- lib/lookout-3.0/diff/formats/inline.rb
Instance Method Summary collapse
- #copy(operation) ⇒ Object
- #delete(operation) ⇒ Object
-
#initialize(operations) ⇒ ToS
constructor
A new instance of ToS.
- #insert(operation) ⇒ Object
- #replace(operation) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(operations) ⇒ ToS
Returns a new instance of ToS.
36 |
# File 'lib/lookout-3.0/diff/formats/inline.rb', line 36 def initialize(operations) @to_s = operations.map{ |o| o.apply(self) }.join('').freeze end |
Instance Method Details
#copy(operation) ⇒ Object
38 |
# File 'lib/lookout-3.0/diff/formats/inline.rb', line 38 def copy(operation) operation.old.to_items end |
#delete(operation) ⇒ Object
37 |
# File 'lib/lookout-3.0/diff/formats/inline.rb', line 37 def delete(operation) '[-%s-]' % operation.old.to_items end |
#insert(operation) ⇒ Object
39 |
# File 'lib/lookout-3.0/diff/formats/inline.rb', line 39 def insert(operation) '{+%s+}' % operation.new.to_items end |
#replace(operation) ⇒ Object
40 |
# File 'lib/lookout-3.0/diff/formats/inline.rb', line 40 def replace(operation) delete(operation) + insert(operation) end |
#to_s ⇒ Object
41 |
# File 'lib/lookout-3.0/diff/formats/inline.rb', line 41 def to_s; @to_s end |