Module: Symphony::Metronome::TimeFunctions
- Included in:
- IntervalExpression
- Defined in:
- lib/symphony/metronome/mixins.rb
Overview
Functions for time calculations
Class Method Summary collapse
-
.calculate_seconds(count, unit) ⇒ Object
Calculate the (approximate) number of seconds that are in
countof the givenunitof time.
Class Method Details
.calculate_seconds(count, unit) ⇒ Object
Calculate the (approximate) number of seconds that are in count of the given unit of time.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/symphony/metronome/mixins.rb', line 21 def calculate_seconds( count, unit ) return case unit when :seconds, :second count when :minutes, :minute count * 60 when :hours, :hour count * 3600 when :days, :day count * 86400 when :weeks, :week count * 604800 when :fortnights, :fortnight count * 1209600 when :months, :month count * 2592000 when :years, :year count * 31557600 else raise ArgumentError, "don't know how to calculate seconds in a %p" % [ unit ] end end |