Class: Almicube::AssociationProxy
- Inherits:
-
Object
- Object
- Almicube::AssociationProxy
- Defined in:
- lib/almicube/proxy/association_proxy.rb
Instance Method Summary collapse
- #incr(score = 1) ⇒ Object
-
#initialize(ranking, item) ⇒ AssociationProxy
constructor
A new instance of AssociationProxy.
- #rank ⇒ Object
- #score ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(ranking, item) ⇒ AssociationProxy
Returns a new instance of AssociationProxy.
3 4 5 6 7 |
# File 'lib/almicube/proxy/association_proxy.rb', line 3 def initialize(ranking, item) raise TypeError, "without the Almicube::Ranking as #1 argument" unless ranking.kind_of? Ranking::Base @item = item @ranking = ranking end |
Instance Method Details
#incr(score = 1) ⇒ Object
17 18 19 |
# File 'lib/almicube/proxy/association_proxy.rb', line 17 def incr(score = 1) @ranking.incr(@item, score) end |
#rank ⇒ Object
13 14 15 |
# File 'lib/almicube/proxy/association_proxy.rb', line 13 def rank @ranking.rank(@item) end |
#score ⇒ Object
9 10 11 |
# File 'lib/almicube/proxy/association_proxy.rb', line 9 def score @ranking.score(@item) end |
#to_s ⇒ Object
21 22 23 |
# File 'lib/almicube/proxy/association_proxy.rb', line 21 def to_s "#{@item.to_s}: #{@ranking.key} [#{rank} - #{score}]" end |