Class: Lockistics::Statistics
- Inherits:
-
Object
- Object
- Lockistics::Statistics
- Defined in:
- lib/lockistics/statistics.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
Returns the value of attribute key.
Instance Method Summary collapse
- #all(since = nil) ⇒ Object
- #daily(since = nil) ⇒ Object
- #hourly(since = nil) ⇒ Object
-
#initialize(key) ⇒ Statistics
constructor
A new instance of Statistics.
- #last_run ⇒ Object
- #total ⇒ Object
Constructor Details
#initialize(key) ⇒ Statistics
7 8 9 |
# File 'lib/lockistics/statistics.rb', line 7 def initialize(key) @key = key end |
Instance Attribute Details
#key ⇒ Object
Returns the value of attribute key.
5 6 7 |
# File 'lib/lockistics/statistics.rb', line 5 def key @key end |
Instance Method Details
#all(since = nil) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/lockistics/statistics.rb', line 18 def all(since=nil) { :daily => daily(since), :hourly => hourly(since), :total => total, :last_run => last_run } end |
#daily(since = nil) ⇒ Object
27 28 29 |
# File 'lib/lockistics/statistics.rb', line 27 def daily(since=nil) daily_hashes(since).collect{|stamped| redis.hgetall(stamped.first).merge(:time => stamped.last )} end |
#hourly(since = nil) ⇒ Object
31 32 33 |
# File 'lib/lockistics/statistics.rb', line 31 def hourly(since=nil) hourly_hashes(since).collect{|stamped| redis.hgetall(stamped.first).merge(:time => stamped.last)} end |
#last_run ⇒ Object
11 12 13 14 15 16 |
# File 'lib/lockistics/statistics.rb', line 11 def last_run unix_time = redis.get(namespaced("#{key}.last_run")) if unix_time Time.at(unix_time.to_i) end end |
#total ⇒ Object
35 36 37 |
# File 'lib/lockistics/statistics.rb', line 35 def total redis.hgetall total_hash end |