Class: Inch::Evaluation::Role::Base Abstract
- Inherits:
-
Object
- Object
- Inch::Evaluation::Role::Base
- Defined in:
- lib/inch/evaluation/role/base.rb
Overview
Direct Known Subclasses
Method::Constructor, Method::Getter, Method::HasAlias, Method::Overridden, Method::Setter, Method::WithBangName, Method::WithManyLines, Method::WithManyParameters, Method::WithQuestioningName, Method::WithReturnDescription, Method::WithReturnType, Method::WithoutParameters, MethodParameter::Block, MethodParameter::Splat, MethodParameter::WithBadName, MethodParameter::WithMention, MethodParameter::WithType, MethodParameter::WithWrongMention, Missing, Namespace::Core, Namespace::Pure, Namespace::WithChildren, Namespace::WithManyAttributes, Namespace::WithManyChildren, Namespace::WithoutChildren, Namespace::WithoutMethods, Object::Alias, Object::InRoot, Object::Private, Object::Protected, Object::Public, Object::Tagged, Object::TaggedAsAPI, Object::TaggedAsInternalAPI, Object::TaggedAsNodoc, Object::TaggedAsPrivate, Object::WithCodeExample, Object::WithDoc, Object::WithMultipleCodeExamples
Instance Attribute Summary collapse
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Class Method Summary collapse
- .applicable?(object) ⇒ Boolean
- .applicable_if(symbol = nil, &block) ⇒ Object
- .applicable_unless(symbol = nil, &block) ⇒ Object
Instance Method Summary collapse
-
#initialize(object, value = nil) ⇒ Base
constructor
A new instance of Base.
-
#max_score ⇒ Float
Returns a maximal score for the object.
-
#min_score ⇒ Float
Returns a minimal score for the object.
- #object_type ⇒ Object
-
#potential_score ⇒ Float
Returns a potential score that would be added to the overall score if the object had implemented the Role’s subject.
-
#priority ⇒ Fixnum
Returns a priority that will be added to the associated object’s overall priority.
-
#score ⇒ Float
Returns a score that will be added to the associated object’s overall score.
-
#suggestion ⇒ Float
Returns a suggestion to achieve the potential score that would be added to the overall score if the object had implemented the Role’s subject.
Constructor Details
#initialize(object, value = nil) ⇒ Base
Returns a new instance of Base.
29 30 31 32 |
# File 'lib/inch/evaluation/role/base.rb', line 29 def initialize(object, value = nil) @object = object @value = value end |
Instance Attribute Details
#object ⇒ Object (readonly)
Returns the value of attribute object.
8 9 10 |
# File 'lib/inch/evaluation/role/base.rb', line 8 def object @object end |
Class Method Details
.applicable?(object) ⇒ Boolean
23 24 25 26 |
# File 'lib/inch/evaluation/role/base.rb', line 23 def applicable?(object) @applicable_procs ||= {} @applicable_procs[to_s].call(object) end |
.applicable_if(symbol = nil, &block) ⇒ Object
11 12 13 14 |
# File 'lib/inch/evaluation/role/base.rb', line 11 def applicable_if(symbol = nil, &block) @applicable_procs ||= {} @applicable_procs[to_s] = block || symbol.to_proc end |
.applicable_unless(symbol = nil, &block) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/inch/evaluation/role/base.rb', line 16 def applicable_unless(symbol = nil, &block) @applicable_procs ||= {} @applicable_procs[to_s] = proc do |object| !(block || symbol.to_proc).call(object) end end |
Instance Method Details
#max_score ⇒ Float
Override this method to that a max_score for the evaluation.
Returns a maximal score for the object. The final score can not be higher than this.
38 39 |
# File 'lib/inch/evaluation/role/base.rb', line 38 def max_score end |
#min_score ⇒ Float
Override this method to that a min_score for the evaluation.
Returns a minimal score for the object. The final score can not be lower than this.
45 46 |
# File 'lib/inch/evaluation/role/base.rb', line 45 def min_score end |
#object_type ⇒ Object
86 87 88 |
# File 'lib/inch/evaluation/role/base.rb', line 86 def object_type object.class.to_s.split('::').last.gsub(/Object$/, '').downcase end |
#potential_score ⇒ Float
Override this method to assign a potential score for the role
Returns a potential score that would be added to the overall score if the object had implemented the Role’s subject.
63 64 65 |
# File 'lib/inch/evaluation/role/base.rb', line 63 def potential_score nil end |
#priority ⇒ Fixnum
Override this method to assign a priority for the role
Returns a priority that will be added to the associated object’s overall priority.
72 73 74 |
# File 'lib/inch/evaluation/role/base.rb', line 72 def priority 0 end |
#score ⇒ Float
Override this method to assign a score for the role
Returns a score that will be added to the associated object’s overall score.
53 54 55 |
# File 'lib/inch/evaluation/role/base.rb', line 53 def score @value.to_f end |
#suggestion ⇒ Float
Returns a suggestion to achieve the potential score that would be added to the overall score if the object had implemented the Role’s subject.
82 83 84 |
# File 'lib/inch/evaluation/role/base.rb', line 82 def suggestion nil end |