Class: Graphite::Tools::WhisperCalc
- Inherits:
-
Object
- Object
- Graphite::Tools::WhisperCalc
- Defined in:
- lib/graphite/tools/whisper_calc.rb
Instance Attribute Summary collapse
-
#aggregation ⇒ Object
readonly
Returns the value of attribute aggregation.
Instance Method Summary collapse
-
#initialize(aggregation) ⇒ WhisperCalc
constructor
A new instance of WhisperCalc.
- #to_h ⇒ Object
- #to_i ⇒ Object
Constructor Details
#initialize(aggregation) ⇒ WhisperCalc
Returns a new instance of WhisperCalc.
10 11 12 |
# File 'lib/graphite/tools/whisper_calc.rb', line 10 def initialize(aggregation) @aggregation = aggregation end |
Instance Attribute Details
#aggregation ⇒ Object (readonly)
Returns the value of attribute aggregation.
8 9 10 |
# File 'lib/graphite/tools/whisper_calc.rb', line 8 def aggregation @aggregation end |
Instance Method Details
#to_h ⇒ Object
14 15 16 |
# File 'lib/graphite/tools/whisper_calc.rb', line 14 def to_h Hash[aggregation.split(',').map { |x| x.split(':').map(&:strip) }] end |
#to_i ⇒ Object
18 19 20 21 22 |
# File 'lib/graphite/tools/whisper_calc.rb', line 18 def to_i to_h.inject(0) do |i, (k, v)| i + frequency_as_i(v) / frequency_as_i(k) end end |