Class: Cheer::Leaderboard
- Inherits:
-
Object
- Object
- Cheer::Leaderboard
- Defined in:
- lib/cheer/leaderboard.rb
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Leaderboard
constructor
A new instance of Leaderboard.
- #to_hash(user_limit = 3) ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Leaderboard
Returns a new instance of Leaderboard.
4 5 6 7 8 9 |
# File 'lib/cheer/leaderboard.rb', line 4 def initialize(attributes = {}) @model_klass = attributes[:model_klass] @rank_evaluator = attributes[:rank_evaluator] define_public_methods end |
Instance Method Details
#to_hash(user_limit = 3) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/cheer/leaderboard.rb', line 11 def to_hash(user_limit = 3) { standing_methods[:current_rank] => self.public_send(standing_methods[:current_rank]), standing_methods[:rank_around] => self.public_send(standing_methods[:rank_around]), standing_methods[:top_rankers] => self.public_send(standing_methods[:top_rankers], user_limit) } end |