Class: Trifle::Stats::Driver::Process
- Inherits:
-
Object
- Object
- Trifle::Stats::Driver::Process
- Includes:
- Mixins::Packer
- Defined in:
- lib/trifle/stats/driver/process.rb
Instance Method Summary collapse
- #description ⇒ Object
- #get(keys:) ⇒ Object
- #inc(keys:, **values) ⇒ Object
-
#initialize ⇒ Process
constructor
A new instance of Process.
- #ping ⇒ Object
- #scan ⇒ Object
- #set(keys:, **values) ⇒ Object
Methods included from Mixins::Packer
Constructor Details
#initialize ⇒ Process
Returns a new instance of Process.
10 11 12 13 |
# File 'lib/trifle/stats/driver/process.rb', line 10 def initialize @data = {} @separator = '::' end |
Instance Method Details
#description ⇒ Object
15 16 17 |
# File 'lib/trifle/stats/driver/process.rb', line 15 def description "#{self.class.name}(J)" end |
#get(keys:) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/trifle/stats/driver/process.rb', line 39 def get(keys:) keys.map do |key| self.class.unpack( hash: @data.fetch(key.join(@separator), {}) ) end end |
#inc(keys:, **values) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/trifle/stats/driver/process.rb', line 19 def inc(keys:, **values) keys.map do |key| self.class.pack(hash: values).each do |k, c| d = @data.fetch(key.join(@separator), {}) d[k] = d[k].to_i + c @data[key.join(@separator)] = d end end end |
#ping ⇒ Object
47 48 49 |
# File 'lib/trifle/stats/driver/process.rb', line 47 def ping(*) [] end |
#scan ⇒ Object
51 52 53 |
# File 'lib/trifle/stats/driver/process.rb', line 51 def scan(*) [] end |
#set(keys:, **values) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/trifle/stats/driver/process.rb', line 29 def set(keys:, **values) keys.map do |key| self.class.pack(hash: values).each do |k, c| d = @data.fetch(key.join(@separator), {}) d[k] = c @data[key.join(@separator)] = d end end end |