Module: Kthxbye::Stats
Instance Method Summary collapse
-
#decr(stat, by = 1) ⇒ Object
decrement a count by a given value (defaults to 1).
-
#get(stat) ⇒ Object
(also: #[])
get count for a given stat (can also use [] method).
-
#incr(stat, by = 1) ⇒ Object
increment a count by a given value (defaults to 1).
-
#reset(stat) ⇒ Object
reset this stat to 0.
Methods included from Helper
Instance Method Details
#decr(stat, by = 1) ⇒ Object
decrement a count by a given value (defaults to 1)
29 30 31 |
# File 'lib/kthxbye/stats.rb', line 29 def decr( stat, by=1 ) redis.decrby("stat:#{stat}", by) end |
#get(stat) ⇒ Object Also known as: []
get count for a given stat (can also use [] method)
18 19 20 |
# File 'lib/kthxbye/stats.rb', line 18 def get( stat ) redis.get( "stat:#{stat}" ).to_i end |
#incr(stat, by = 1) ⇒ Object
increment a count by a given value (defaults to 1)
24 25 26 |
# File 'lib/kthxbye/stats.rb', line 24 def incr( stat, by=1 ) redis.incrby("stat:#{stat}", by) end |
#reset(stat) ⇒ Object
reset this stat to 0
34 35 36 |
# File 'lib/kthxbye/stats.rb', line 34 def reset( stat ) redis.del( "stat:#{stat}" ) end |