Class: ChunkDiffer
- Inherits:
-
Object
- Object
- ChunkDiffer
- Defined in:
- app/models/revision.rb
Constant Summary collapse
- LCS_ACTION_TO_SYMBOL =
{'=' => :unchanged, '!' => :modification, '-' => :deletion, '+' => :addition}
Instance Method Summary collapse
- #diff(old_lines, new_lines) ⇒ Object
- #get_result ⇒ Object
- #start_new_chunk(action) ⇒ Object
- #store_diff(sdiff) ⇒ Object
Instance Method Details
#diff(old_lines, new_lines) ⇒ Object
37 38 39 40 |
# File 'app/models/revision.rb', line 37 def diff(old_lines, new_lines) @chunks = [] Differ.new(self).diff(old_lines, new_lines) end |
#get_result ⇒ Object
56 57 58 |
# File 'app/models/revision.rb', line 56 def get_result @chunks end |
#start_new_chunk(action) ⇒ Object
45 46 47 48 |
# File 'app/models/revision.rb', line 45 def start_new_chunk(action) @chunk = Chunk.new(LCS_ACTION_TO_SYMBOL[action]) @chunks << @chunk end |