Class: Convection::Model::Diff
- Inherits:
-
Object
- Object
- Convection::Model::Diff
- Extended by:
- Mixin::Colorize
- Defined in:
- lib/convection/model/diff.rb
Overview
Difference between an item in two templates
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#ours ⇒ Object
readonly
Returns the value of attribute ours.
-
#theirs ⇒ Object
readonly
Returns the value of attribute theirs.
Instance Method Summary collapse
-
#initialize(key, ours, theirs) ⇒ Diff
constructor
A new instance of Diff.
- #to_thor ⇒ Object
Methods included from Mixin::Colorize
Constructor Details
#initialize(key, ours, theirs) ⇒ Diff
Returns a new instance of Diff
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/convection/model/diff.rb', line 17 def initialize(key, ours, theirs) @key = key @ours = ours @theirs = theirs @action = if ours && theirs then :update elsif ours then :create else :delete end end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action
12 13 14 |
# File 'lib/convection/model/diff.rb', line 12 def action @action end |
#key ⇒ Object (readonly)
Returns the value of attribute key
11 12 13 |
# File 'lib/convection/model/diff.rb', line 11 def key @key end |
#ours ⇒ Object (readonly)
Returns the value of attribute ours
13 14 15 |
# File 'lib/convection/model/diff.rb', line 13 def ours @ours end |
#theirs ⇒ Object (readonly)
Returns the value of attribute theirs
14 15 16 |
# File 'lib/convection/model/diff.rb', line 14 def theirs @theirs end |
Instance Method Details
#to_thor ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/convection/model/diff.rb', line 28 def to_thor = case action when :create then "#{ key }: #{ ours }" when :update then "#{ key }: #{ theirs } => #{ ours }" when :delete then key end [action, , color] end |