Class: SplitIoClient::SumAndCount
- Inherits:
-
Object
- Object
- SplitIoClient::SumAndCount
- Defined in:
- lib/engine/metrics/metrics.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.
118 119 120 121 |
# File 'lib/engine/metrics/metrics.rb', line 118 def initialize @count = 0 @sum = 0 end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
115 116 117 |
# File 'lib/engine/metrics/metrics.rb', line 115 def count @count end |
#sum ⇒ Object (readonly)
Returns the value of attribute sum.
116 117 118 |
# File 'lib/engine/metrics/metrics.rb', line 116 def sum @sum end |
Instance Method Details
#add_delta(delta) ⇒ Object
123 124 125 126 |
# File 'lib/engine/metrics/metrics.rb', line 123 def add_delta(delta) @count++ @sum += delta end |
#clear ⇒ Object
128 129 130 131 |
# File 'lib/engine/metrics/metrics.rb', line 128 def clear @count = 0 @sum = 0 end |