Module: Zenaton::Traits::WithDuration

Included in:
WithTimestamp
Defined in:
lib/zenaton/traits/with_duration.rb

Overview

Module to calculate duration between events

Instance Method Summary collapse

Instance Method Details

#_get_durationInteger, NilClass

Returns Duration in seconds.

Returns:

  • (Integer, NilClass)

    Duration in seconds



10
11
12
13
14
15
16
17
# File 'lib/zenaton/traits/with_duration.rb', line 10

def _get_duration
  return unless @buffer
  now, now_dup = _init_now_then
  @buffer.each do |time_unit, time_value|
    now_dup = _apply_duration(time_unit, time_value, now_dup)
  end
  diff_in_seconds(now, now_dup)
end