Class: DatadogCompoundMetrics::CompoundMetric
- Inherits:
-
Object
- Object
- DatadogCompoundMetrics::CompoundMetric
- Defined in:
- lib/datadog_compound_metrics/compound_metric.rb
Instance Attribute Summary collapse
-
#calculation_strategy ⇒ Object
Returns the value of attribute calculation_strategy.
-
#calculations ⇒ Object
readonly
Returns the value of attribute calculations.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #add_calculation(calculation) ⇒ Object
- #compute ⇒ Object
-
#initialize(name) ⇒ CompoundMetric
constructor
A new instance of CompoundMetric.
Constructor Details
#initialize(name) ⇒ CompoundMetric
Returns a new instance of CompoundMetric.
8 9 10 11 |
# File 'lib/datadog_compound_metrics/compound_metric.rb', line 8 def initialize(name) @name = name @calculations = [] end |
Instance Attribute Details
#calculation_strategy ⇒ Object
Returns the value of attribute calculation_strategy.
6 7 8 |
# File 'lib/datadog_compound_metrics/compound_metric.rb', line 6 def calculation_strategy @calculation_strategy end |
#calculations ⇒ Object (readonly)
Returns the value of attribute calculations.
5 6 7 |
# File 'lib/datadog_compound_metrics/compound_metric.rb', line 5 def calculations @calculations end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/datadog_compound_metrics/compound_metric.rb', line 5 def name @name end |
Instance Method Details
#add_calculation(calculation) ⇒ Object
13 14 15 |
# File 'lib/datadog_compound_metrics/compound_metric.rb', line 13 def add_calculation(calculation) calculations << calculation end |
#compute ⇒ Object
17 18 19 20 21 |
# File 'lib/datadog_compound_metrics/compound_metric.rb', line 17 def compute calculations .map(&:call) .public_send(calculation_strategy) end |