Module: Ranking::InstanceMethods
- Included in:
- Ranking
- Defined in:
- lib/ranking/instance_methods.rb
Instance Method Summary collapse
- #[](*args) ⇒ Object
- #dec(object, value = 1) ⇒ Object
- #inc(object, value = 1) ⇒ Object
- #initialize(*args) ⇒ Object
- #score(object, value) ⇒ Object
Instance Method Details
#[](*args) ⇒ Object
25 26 27 |
# File 'lib/ranking/instance_methods.rb', line 25 def [](*args) to_a[*args] end |
#dec(object, value = 1) ⇒ Object
13 14 15 16 17 |
# File 'lib/ranking/instance_methods.rb', line 13 def dec(object, value=1) self << object scores[object] -= value self end |
#inc(object, value = 1) ⇒ Object
7 8 9 10 11 |
# File 'lib/ranking/instance_methods.rb', line 7 def inc(object, value=1) self << object scores[object] += value self end |
#initialize(*args) ⇒ Object
2 3 4 5 |
# File 'lib/ranking/instance_methods.rb', line 2 def initialize(*args) @scores = Hash.new(0) super *args end |
#score(object, value) ⇒ Object
19 20 21 22 23 |
# File 'lib/ranking/instance_methods.rb', line 19 def score(object, value) self << object scores[object] = value self end |