Class: Metriksd::LibratoMetricsReporter::TimesliceRollup::AverageGauge
- Inherits:
-
Object
- Object
- Metriksd::LibratoMetricsReporter::TimesliceRollup::AverageGauge
- Defined in:
- lib/metriksd/librato_metrics_reporter/timeslice_rollup.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
Returns the value of attribute count.
-
#max ⇒ Object
Returns the value of attribute max.
-
#min ⇒ Object
Returns the value of attribute min.
-
#name ⇒ Object
Returns the value of attribute name.
-
#source ⇒ Object
Returns the value of attribute source.
-
#sum ⇒ Object
Returns the value of attribute sum.
-
#sum_squares ⇒ Object
Returns the value of attribute sum_squares.
Instance Method Summary collapse
-
#initialize(name, source) ⇒ AverageGauge
constructor
A new instance of AverageGauge.
- #mark(value) ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(name, source) ⇒ AverageGauge
Returns a new instance of AverageGauge.
6 7 8 9 10 11 12 13 14 |
# File 'lib/metriksd/librato_metrics_reporter/timeslice_rollup.rb', line 6 def initialize(name, source) @name = name @source = source @count = 0 @sum = 0 @sum_squares = 0 @min = nil @max = nil end |
Instance Attribute Details
#count ⇒ Object
Returns the value of attribute count.
4 5 6 |
# File 'lib/metriksd/librato_metrics_reporter/timeslice_rollup.rb', line 4 def count @count end |
#max ⇒ Object
Returns the value of attribute max.
4 5 6 |
# File 'lib/metriksd/librato_metrics_reporter/timeslice_rollup.rb', line 4 def max @max end |
#min ⇒ Object
Returns the value of attribute min.
4 5 6 |
# File 'lib/metriksd/librato_metrics_reporter/timeslice_rollup.rb', line 4 def min @min end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/metriksd/librato_metrics_reporter/timeslice_rollup.rb', line 4 def name @name end |
#source ⇒ Object
Returns the value of attribute source.
4 5 6 |
# File 'lib/metriksd/librato_metrics_reporter/timeslice_rollup.rb', line 4 def source @source end |
#sum ⇒ Object
Returns the value of attribute sum.
4 5 6 |
# File 'lib/metriksd/librato_metrics_reporter/timeslice_rollup.rb', line 4 def sum @sum end |
#sum_squares ⇒ Object
Returns the value of attribute sum_squares.
4 5 6 |
# File 'lib/metriksd/librato_metrics_reporter/timeslice_rollup.rb', line 4 def sum_squares @sum_squares end |
Instance Method Details
#mark(value) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/metriksd/librato_metrics_reporter/timeslice_rollup.rb', line 16 def mark(value) @count += 1 @sum += value @sum_squares += value ** 2 if !@min || value < @min @min = value end if !@max || value > @max @max = value end end |
#to_hash ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/metriksd/librato_metrics_reporter/timeslice_rollup.rb', line 30 def to_hash { :name => name, :source => source, :count => count, :sum => sum, :sum_squares => sum_squares, :min => min, :max => max } end |