mirror of
https://github.com/jimeh/redistat.git
synced 2026-02-19 13:26:39 +00:00
Created Redistat::Result and started using it
Finder. All specs pass.
This commit is contained in:
@@ -27,6 +27,8 @@ module Redistat
|
||||
total_sum.set_or_incr(k, v.to_i)
|
||||
end
|
||||
end
|
||||
total_sum.date = Date.new(@options[:from], @options[:depth])
|
||||
total_sum.till = Date.new(@options[:till], @options[:depth])
|
||||
total_sum
|
||||
end
|
||||
|
||||
|
||||
14
lib/redistat/result.rb
Normal file
14
lib/redistat/result.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
module Redistat
|
||||
class Result < ::Hash
|
||||
|
||||
attr_accessor :date
|
||||
attr_accessor :till
|
||||
|
||||
def set_or_incr(key, value)
|
||||
self[key] = 0 if !self.has_key?(key)
|
||||
self[key] += value
|
||||
self
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user