Class: Lookout::Diff::Formats::Hash::Operation
- Defined in:
- lib/lookout/diff/formats/hash.rb
Instance Method Summary collapse
- #delete(operation) ⇒ Object
- #empty? ⇒ Boolean
- #equal(operation) ⇒ Object
-
#initialize(operation) ⇒ Operation
constructor
A new instance of Operation.
- #insert(operation) ⇒ Object
- #replace(operation) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(operation) ⇒ Operation
Returns a new instance of Operation.
20 21 22 |
# File 'lib/lookout/diff/formats/hash.rb', line 20 def initialize(operation) @lines = operation.apply(self) end |
Instance Method Details
#delete(operation) ⇒ Object
28 29 30 |
# File 'lib/lookout/diff/formats/hash.rb', line 28 def delete(operation) mark('-', operation.from) end |
#empty? ⇒ Boolean
24 25 26 |
# File 'lib/lookout/diff/formats/hash.rb', line 24 def empty? @lines.nil? end |
#equal(operation) ⇒ Object
32 33 |
# File 'lib/lookout/diff/formats/hash.rb', line 32 def equal(operation) end |
#insert(operation) ⇒ Object
35 36 37 |
# File 'lib/lookout/diff/formats/hash.rb', line 35 def insert(operation) mark('+', operation.to) end |
#replace(operation) ⇒ Object
39 40 41 |
# File 'lib/lookout/diff/formats/hash.rb', line 39 def replace(operation) delete(operation) + insert(operation) end |
#to_s ⇒ Object
43 44 45 |
# File 'lib/lookout/diff/formats/hash.rb', line 43 def to_s @lines.join("\n") end |