module Ranking::InstanceMethods
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
# File lib/ranking/instance_methods.rb, line 2 def initialize(*args) @scores = Hash.new(0) super *args end
Public Instance Methods
[](*args)
click to toggle source
# File lib/ranking/instance_methods.rb, line 25 def [](*args) to_a[*args] end
dec(object, value=1)
click to toggle source
# File lib/ranking/instance_methods.rb, line 13 def dec(object, value=1) self << object scores[object] -= value self end
inc(object, value=1)
click to toggle source
# File lib/ranking/instance_methods.rb, line 7 def inc(object, value=1) self << object scores[object] += value self end
score(object, value)
click to toggle source
# File lib/ranking/instance_methods.rb, line 19 def score(object, value) self << object scores[object] = value self end