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 fail '@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
26 27 28 |
# File 'lib/inch/api/compare/code_objects.rb', line 26 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
30 31 32 |
# File 'lib/inch/api/compare/code_objects.rb', line 30 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
34 35 36 |
# File 'lib/inch/api/compare/code_objects.rb', line 34 def improved? changed? && @before.score < @after.score end |
#present? ⇒ Boolean
38 39 40 |
# File 'lib/inch/api/compare/code_objects.rb', line 38 def present? @before && @after end |
#removed? ⇒ Boolean
42 43 44 |
# File 'lib/inch/api/compare/code_objects.rb', line 42 def removed? !@before.nil? && @after.nil? end |
#scores ⇒ Object
50 51 52 |
# File 'lib/inch/api/compare/code_objects.rb', line 50 def scores [@before.score, @after.score] end |
#unchanged? ⇒ Boolean
46 47 48 |
# File 'lib/inch/api/compare/code_objects.rb', line 46 def unchanged? present? && @before.score == @after.score end |