Method: Hitimes::TimedValueMetric#split

Defined in:
lib/hitimes/timed_value_metric.rb

#split(value) ⇒ Object

:call-seq:

timed_value_metric.split( value ) -> Float

Split the current metric. Essentially, mark a split time. This means stop the current interval, with the givein value and create a new interval, but make sure that the new interval lines up exactly, timewise, behind the previous interval.

If the metric is running, then split returns the duration of the previous interval, i.e. the split-time. If the metric is not running, nothing happens, no stats are updated, and false is returned.



156
157
158
159
160
161
162
163
164
165
166
# File 'lib/hitimes/timed_value_metric.rb', line 156

def split(value)
  if @current_interval.running?
    next_interval = @current_interval.split
    duration = @current_interval.duration
    @timed_stats.update(duration)
    @value_stats.update(value)
    @current_interval = next_interval
    return duration
  end
  false
end