Class: CodeChange
- Inherits:
-
Object
- Object
- CodeChange
- Defined in:
- lib/ruby_diff/code_comparison.rb
Constant Summary collapse
- OPERATION_CHARS =
{ :added => "+", :removed => "-", :changed => "c", :moved => "m" #Not used yet }
Instance Attribute Summary collapse
-
#changes ⇒ Object
readonly
Returns the value of attribute changes.
-
#operation ⇒ Object
readonly
Returns the value of attribute operation.
-
#signature ⇒ Object
readonly
Returns the value of attribute signature.
Instance Method Summary collapse
-
#initialize(signature, operation, changes = []) ⇒ CodeChange
constructor
A new instance of CodeChange.
- #to_s(depth = 1) ⇒ Object
Constructor Details
#initialize(signature, operation, changes = []) ⇒ CodeChange
13 14 15 16 17 |
# File 'lib/ruby_diff/code_comparison.rb', line 13 def initialize(signature, operation, changes=[]) @signature = signature @operation = operation @changes = changes end |
Instance Attribute Details
#changes ⇒ Object (readonly)
Returns the value of attribute changes.
4 5 6 |
# File 'lib/ruby_diff/code_comparison.rb', line 4 def changes @changes end |
#operation ⇒ Object (readonly)
Returns the value of attribute operation.
3 4 5 |
# File 'lib/ruby_diff/code_comparison.rb', line 3 def operation @operation end |
#signature ⇒ Object (readonly)
Returns the value of attribute signature.
2 3 4 |
# File 'lib/ruby_diff/code_comparison.rb', line 2 def signature @signature end |
Instance Method Details
#to_s(depth = 1) ⇒ Object
19 20 21 22 23 |
# File 'lib/ruby_diff/code_comparison.rb', line 19 def to_s(depth=1) this_change = "#{OPERATION_CHARS[self.operation]}#{" "*depth}#{signature}" sub_changes = changes.map{|c| c.to_s(depth+1)} [this_change, sub_changes].flatten.join("\n") end |