Sha256: dd2a84dc160223679eda7bdfea465ca88ef137512f3dd34902bb065701b102ec
Contents?: true
Size: 1.04 KB
Versions: 4
Compression:
Stored size: 1.04 KB
Contents
module Inch module Evaluation class Base extend Forwardable MIN_SCORE = 0 MAX_SCORE = 100 TAGGED_SCORE = 20 # assigned per unconsidered tag attr_accessor :object attr_reader :min_score, :max_score def initialize(object) self.object = object @roles = [] evaluate end def evaluate end def max_score arr = @roles.map(&:max_score).compact [MAX_SCORE].concat(arr).min end def min_score arr = @roles.map(&:min_score).compact [MIN_SCORE].concat(arr).max end 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 def priority @roles.inject(0) { |sum,r| sum + r.priority.to_i } end def roles @roles end protected def add_role(role) @roles << role end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
inch-0.1.3 | lib/inch/evaluation/base.rb |
inch-0.1.2 | lib/inch/evaluation/base.rb |
inch-0.1.1 | lib/inch/evaluation/base.rb |
inch-0.1.0 | lib/inch/evaluation/base.rb |