Class: Inch::API::Compare::CodeObjects
- Inherits:
-
Object
- Object
- Inch::API::Compare::CodeObjects
- Defined in:
- lib/inch/api/compare/code_objects.rb
Instance Attribute Summary collapse
-
#after ⇒ Object
readonly
Returns the value of attribute after.
-
#before ⇒ Object
readonly
Returns the value of attribute before.
Instance Method Summary collapse
- #added? ⇒ Boolean
- #changed? ⇒ Boolean
- #degraded? ⇒ Boolean
- #fullname ⇒ Object
- #grade ⇒ Object
- #improved? ⇒ Boolean
-
#initialize(object1, object2) ⇒ CodeObjects
constructor
A new instance of CodeObjects.
- #present? ⇒ Boolean
- #removed? ⇒ Boolean
- #scores ⇒ Object
- #unchanged? ⇒ Boolean
Constructor Details
#initialize(object1, object2) ⇒ CodeObjects
Returns a new instance of CodeObjects.
7 8 9 10 11 12 |
# File 'lib/inch/api/compare/code_objects.rb', line 7 def initialize(object1, object2) @before, @after = object1, object2 if @before.object_id == @after.object_id raise "@before and @after are identical ruby objects. this is bad." end end |
Instance Attribute Details
#after ⇒ Object (readonly)
Returns the value of attribute after.
5 6 7 |
# File 'lib/inch/api/compare/code_objects.rb', line 5 def after @after end |
#before ⇒ Object (readonly)
Returns the value of attribute before.
5 6 7 |
# File 'lib/inch/api/compare/code_objects.rb', line 5 def before @before end |
Instance Method Details
#added? ⇒ Boolean
27 28 29 |
# File 'lib/inch/api/compare/code_objects.rb', line 27 def added? @before.nil? && !@after.nil? end |
#changed? ⇒ Boolean
14 15 16 |
# File 'lib/inch/api/compare/code_objects.rb', line 14 def changed? present? && !unchanged? end |
#degraded? ⇒ Boolean
31 32 33 |
# File 'lib/inch/api/compare/code_objects.rb', line 31 def degraded? changed? && @before.score > @after.score end |
#fullname ⇒ Object
18 19 20 |
# File 'lib/inch/api/compare/code_objects.rb', line 18 def fullname (@before || @after).fullname end |
#grade ⇒ Object
22 23 24 |
# File 'lib/inch/api/compare/code_objects.rb', line 22 def grade @after.grade end |
#improved? ⇒ Boolean
35 36 37 |
# File 'lib/inch/api/compare/code_objects.rb', line 35 def improved? changed? && @before.score < @after.score end |
#present? ⇒ Boolean
39 40 41 |
# File 'lib/inch/api/compare/code_objects.rb', line 39 def present? @before && @after end |
#removed? ⇒ Boolean
43 44 45 |
# File 'lib/inch/api/compare/code_objects.rb', line 43 def removed? !@before.nil? && @after.nil? end |
#scores ⇒ Object
51 52 53 |
# File 'lib/inch/api/compare/code_objects.rb', line 51 def scores [@before.score, @after.score] end |
#unchanged? ⇒ Boolean
47 48 49 |
# File 'lib/inch/api/compare/code_objects.rb', line 47 def unchanged? present? && @before.score == @after.score end |