Class: Ranker::Strategies::ModifiedCompetition
- Defined in:
- lib/ranker/strategies/modified_competition.rb
Overview
Ranks rankables according to: en.wikipedia.org/wiki/Ranking#Modified_competition_ranking_.28.221334.22_ranking.29
Instance Attribute Summary
Attributes inherited from Strategy
Instance Method Summary collapse
-
#execute ⇒ Object
Methods:.
Methods inherited from Strategy
Constructor Details
This class inherits a constructor from Ranker::Strategies::Strategy
Instance Method Details
#execute ⇒ Object
Methods:
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ranker/strategies/modified_competition.rb', line 10 def execute rank = 0 scores_unique_sorted.each_with_index { |score, index| rankables_for_score = rankables_for_score(score) if rank == 0 create_ranking(1, score, rankables_for_score) rank += rankables_for_score.count else rank += rankables_for_score.count create_ranking(rank, score, rankables_for_score) end } end |