Module: Kthxbye::Stats

Extended by:
Helper, Stats
Included in:
Stats
Defined in:
lib/kthxbye/stats.rb

Instance Method Summary collapse

Methods included from Helper

decode, encode, log, redis

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