Class: Lookout::Diff::Formats::Inline::ToS

Inherits:
Object
  • Object
show all
Defined in:
lib/lookout-3.0/diff/formats/inline.rb

Instance Method Summary collapse

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_sObject



41
# File 'lib/lookout-3.0/diff/formats/inline.rb', line 41

def to_s; @to_s end