Class: Inch::Evaluation::Base
- Inherits:
-
Object
- Object
- Inch::Evaluation::Base
- Extended by:
- Forwardable
- Defined in:
- lib/inch/evaluation/base.rb
Direct Known Subclasses
Constant Summary collapse
- MIN_SCORE =
0- MAX_SCORE =
100- TAGGED_SCORE =
assigned per unconsidered tag
20
Instance Attribute Summary collapse
-
#max_score ⇒ Object
readonly
Returns the value of attribute max_score.
-
#min_score ⇒ Object
readonly
Returns the value of attribute min_score.
-
#object ⇒ Object
Returns the value of attribute object.
Instance Method Summary collapse
- #evaluate ⇒ Object
-
#initialize(object) ⇒ Base
constructor
A new instance of Base.
- #priority ⇒ Object
- #roles ⇒ Object
- #score ⇒ Object
Constructor Details
#initialize(object) ⇒ Base
Returns a new instance of Base.
15 16 17 18 19 |
# File 'lib/inch/evaluation/base.rb', line 15 def initialize(object) self.object = object @roles = [] evaluate end |
Instance Attribute Details
#max_score ⇒ Object (readonly)
Returns the value of attribute max_score.
13 14 15 |
# File 'lib/inch/evaluation/base.rb', line 13 def max_score @max_score end |
#min_score ⇒ Object (readonly)
Returns the value of attribute min_score.
13 14 15 |
# File 'lib/inch/evaluation/base.rb', line 13 def min_score @min_score end |
#object ⇒ Object
Returns the value of attribute object.
12 13 14 |
# File 'lib/inch/evaluation/base.rb', line 12 def object @object end |
Instance Method Details
#evaluate ⇒ Object
21 22 |
# File 'lib/inch/evaluation/base.rb', line 21 def evaluate end |
#priority ⇒ Object
45 46 47 |
# File 'lib/inch/evaluation/base.rb', line 45 def priority @roles.inject(0) { |sum,r| sum + r.priority.to_i } end |
#roles ⇒ Object
49 50 51 |
# File 'lib/inch/evaluation/base.rb', line 49 def roles @roles end |
#score ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/inch/evaluation/base.rb', line 34 def score value = @roles.inject(0) { |sum,r| sum + r.score.to_f } if value < min_score min_score elsif value > max_score max_score else value end end |