Class: Ranker::Ranking
- Inherits:
-
Object
- Object
- Ranker::Ranking
- Defined in:
- lib/ranker/ranking.rb
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#rank ⇒ Object
readonly
Returns the value of attribute rank.
-
#rankables ⇒ Object
readonly
Returns the value of attribute rankables.
-
#rankings ⇒ Object
readonly
Returns the value of attribute rankings.
-
#score ⇒ Object
readonly
Returns the value of attribute score.
Instance Method Summary collapse
-
#initialize(rankings, index, rank, score, rankables) ⇒ Ranking
constructor
A new instance of Ranking.
-
#num_rankables ⇒ Object
Properties:.
- #percentile ⇒ Object
- #z_score ⇒ Object
Constructor Details
#initialize(rankings, index, rank, score, rankables) ⇒ Ranking
Returns a new instance of Ranking.
7 8 9 10 11 12 13 |
# File 'lib/ranker/ranking.rb', line 7 def initialize(rankings, index, rank, score, rankables) @rankings = rankings @index = index @rank = rank @score = score @rankables = rankables end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
5 6 7 |
# File 'lib/ranker/ranking.rb', line 5 def index @index end |
#rank ⇒ Object (readonly)
Returns the value of attribute rank.
5 6 7 |
# File 'lib/ranker/ranking.rb', line 5 def rank @rank end |
#rankables ⇒ Object (readonly)
Returns the value of attribute rankables.
5 6 7 |
# File 'lib/ranker/ranking.rb', line 5 def rankables @rankables end |
#rankings ⇒ Object (readonly)
Returns the value of attribute rankings.
5 6 7 |
# File 'lib/ranker/ranking.rb', line 5 def rankings @rankings end |
#score ⇒ Object (readonly)
Returns the value of attribute score.
5 6 7 |
# File 'lib/ranker/ranking.rb', line 5 def score @score end |
Instance Method Details
#num_rankables ⇒ Object
Properties:
17 18 19 |
# File 'lib/ranker/ranking.rb', line 17 def num_rankables rankables.count end |
#percentile ⇒ Object
21 22 23 |
# File 'lib/ranker/ranking.rb', line 21 def percentile @percentile ||= (num_scores_at_or_below.to_f / rankings.num_scores) * 100 end |
#z_score ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/ranker/ranking.rb', line 25 def z_score @z_score ||= if rankings.standard_deviation == 0 0 else (score - rankings.mean) / rankings.standard_deviation end end |