Class: MetricsProcessor::FrequencyMap
- Inherits:
-
Concurrent::Map
- Object
- Concurrent::Map
- MetricsProcessor::FrequencyMap
- Defined in:
- lib/ff/ruby/server/sdk/api/metrics_processor.rb
Instance Method Summary collapse
- #drain_to_map ⇒ Object
- #get(key) ⇒ Object
- #increment(key) ⇒ Object
-
#initialize(options = nil, &block) ⇒ FrequencyMap
constructor
A new instance of FrequencyMap.
Constructor Details
#initialize(options = nil, &block) ⇒ FrequencyMap
Returns a new instance of FrequencyMap.
14 15 16 |
# File 'lib/ff/ruby/server/sdk/api/metrics_processor.rb', line 14 def initialize( = nil, &block) super end |
Instance Method Details
#drain_to_map ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/ff/ruby/server/sdk/api/metrics_processor.rb', line 32 def drain_to_map result = {} each_key do |key| result[key] = 0 end result.each_key do |key| value = get_and_set(key, 0) result[key] = value delete_pair(key, 0) end result end |
#get(key) ⇒ Object
28 29 30 |
# File 'lib/ff/ruby/server/sdk/api/metrics_processor.rb', line 28 def get(key) self[key] end |
#increment(key) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/ff/ruby/server/sdk/api/metrics_processor.rb', line 18 def increment(key) compute(key) do |old_value| if old_value == nil; 1 else old_value + 1 end end end |