Class: Diff::Hunk
Overview
A Hunk stores all information about a contiguous change of the destination list. It stores the inserted and deleted values as well as their positions in the A and B list.
Instance Attribute Summary collapse
-
#aIdx ⇒ Object
Returns the value of attribute aIdx.
-
#bIdx ⇒ Object
Returns the value of attribute bIdx.
-
#deleteValues ⇒ Object
readonly
Returns the value of attribute deleteValues.
-
#insertValues ⇒ Object
readonly
Returns the value of attribute insertValues.
Instance Method Summary collapse
-
#delete? ⇒ Boolean
Has the Hunk any values to be deleted?.
-
#initialize(aIdx, bIdx) ⇒ Hunk
constructor
Create a new Hunk.
-
#insert? ⇒ Boolean
Has the Hunk any values to insert?.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(aIdx, bIdx) ⇒ Hunk
Create a new Hunk. aIdx is the index in the A list. bIdx is the index in the B list.
32 33 34 35 36 37 38 39 40 |
# File 'lib/taskjuggler/AlgorithmDiff.rb', line 32 def initialize(aIdx, bIdx) @aIdx = aIdx # A list of values to be deleted from the A list starting at aIdx. @deleteValues = [] @bIdx = bIdx # A list of values to be inserted into the B list at bIdx. @insertValues = [] end |
Instance Attribute Details
#aIdx ⇒ Object
Returns the value of attribute aIdx.
28 29 30 |
# File 'lib/taskjuggler/AlgorithmDiff.rb', line 28 def aIdx @aIdx end |
#bIdx ⇒ Object
Returns the value of attribute bIdx.
28 29 30 |
# File 'lib/taskjuggler/AlgorithmDiff.rb', line 28 def bIdx @bIdx end |
#deleteValues ⇒ Object (readonly)
Returns the value of attribute deleteValues.
27 28 29 |
# File 'lib/taskjuggler/AlgorithmDiff.rb', line 27 def deleteValues @deleteValues end |
#insertValues ⇒ Object (readonly)
Returns the value of attribute insertValues.
27 28 29 |
# File 'lib/taskjuggler/AlgorithmDiff.rb', line 27 def insertValues @insertValues end |
Instance Method Details
#delete? ⇒ Boolean
Has the Hunk any values to be deleted?
48 49 50 |
# File 'lib/taskjuggler/AlgorithmDiff.rb', line 48 def delete? !@deleteValues.empty? end |
#insert? ⇒ Boolean
Has the Hunk any values to insert?
43 44 45 |
# File 'lib/taskjuggler/AlgorithmDiff.rb', line 43 def insert? !@insertValues.empty? end |
#inspect ⇒ Object
71 72 73 |
# File 'lib/taskjuggler/AlgorithmDiff.rb', line 71 def inspect puts to_s end |
#to_s ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/taskjuggler/AlgorithmDiff.rb', line 52 def to_s str = '' showSeparator = false if insert? && delete? str << "#{aRange}c#{bRange}\n" showSeparator = true elsif insert? str << "#{aIdx}a#{bRange}\n" else str << "#{aRange}d#{bIdx}\n" end @deleteValues.each { |value| str << "< #{value}\n" } str << "---\n" if showSeparator @insertValues.each { |value| str << "> #{value}\n" } str end |