Class: ActiveMetric::Delta

Inherits:
Stat
  • Object
show all
Defined in:
lib/active_metric/statistics/defaults.rb

Instance Method Summary collapse

Methods inherited from Stat

access_name, #access_name, approximation, class_for, #complete, create_custom_stat, #initialize, #property_from, #subject

Constructor Details

This class inherits a constructor from ActiveMetric::Stat

Instance Method Details

#calculate(measurement) ⇒ Object



92
93
94
95
96
97
98
99
100
# File 'lib/active_metric/statistics/defaults.rb', line 92

def calculate(measurement)

  seed_value = property_from(calculable.seed_measurement)
  current_value = property_from(measurement)

  self.first ||= (seed_value || current_value)

  self.value = current_value - first
end