Class: SplitIoClient::Cache::Repositories::Metrics::MemoryRepository::SumAndCount
- Inherits:
-
Object
- Object
- SplitIoClient::Cache::Repositories::Metrics::MemoryRepository::SumAndCount
- Defined in:
- lib/cache/repositories/metrics/memory_repository.rb
Overview
small class to act as DTO for counts
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#sum ⇒ Object
readonly
Returns the value of attribute sum.
Instance Method Summary collapse
- #add_delta(delta) ⇒ Object
- #clear ⇒ Object
-
#initialize ⇒ SumAndCount
constructor
A new instance of SumAndCount.
Constructor Details
#initialize ⇒ SumAndCount
Returns a new instance of SumAndCount.
81 82 83 84 |
# File 'lib/cache/repositories/metrics/memory_repository.rb', line 81 def initialize @count = 0 @sum = 0 end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
78 79 80 |
# File 'lib/cache/repositories/metrics/memory_repository.rb', line 78 def count @count end |
#sum ⇒ Object (readonly)
Returns the value of attribute sum.
79 80 81 |
# File 'lib/cache/repositories/metrics/memory_repository.rb', line 79 def sum @sum end |
Instance Method Details
#add_delta(delta) ⇒ Object
86 87 88 89 |
# File 'lib/cache/repositories/metrics/memory_repository.rb', line 86 def add_delta(delta) @count += 1 @sum += delta end |
#clear ⇒ Object
91 92 93 94 |
# File 'lib/cache/repositories/metrics/memory_repository.rb', line 91 def clear @count = 0 @sum = 0 end |