module Symphony::Metronome::TimeRefinements
Refinements to Numeric to add time-related convenience methods
Public Instance Methods
Returns the Time <receiver> number of seconds after the given time
. E.g., 10.minutes.after( header.expiration )
# File lib/symphony/metronome/mixins.rb, line 114 def after( time ) return time + self end
Returns the Time <receiver> number of seconds ago. (e.g., expiration > 2.hours.ago )
# File lib/symphony/metronome/mixins.rb, line 107 def ago return self.before( ::Time.now ) end
Returns the Time <receiver> number of seconds before the specified time
. E.g., 2.hours.before( header.expiration )
# File lib/symphony/metronome/mixins.rb, line 100 def before( time ) return time - self end
Returns the number of seconds in <receiver> days
# File lib/symphony/metronome/mixins.rb, line 68 def days return TimeFunctions.calculate_seconds( self, :day ) end
Returns the number of seconds in <receiver> fortnights
# File lib/symphony/metronome/mixins.rb, line 80 def fortnights return TimeFunctions.calculate_seconds( self, :fortnights ) end
Return a new Time <receiver> number of seconds from now.
# File lib/symphony/metronome/mixins.rb, line 120 def from_now return self.after( ::Time.now ) end
Returns the number of seconds in <receiver> hours
# File lib/symphony/metronome/mixins.rb, line 62 def hours return TimeFunctions.calculate_seconds( self, :hours ) end
Returns number of seconds in <receiver> minutes
# File lib/symphony/metronome/mixins.rb, line 56 def minutes return TimeFunctions.calculate_seconds( self, :minutes ) end
Returns the number of seconds in <receiver> months (approximate)
# File lib/symphony/metronome/mixins.rb, line 86 def months return TimeFunctions.calculate_seconds( self, :months ) end
Number of seconds (returns receiver unmodified)
# File lib/symphony/metronome/mixins.rb, line 50 def seconds return self end
Return the number of seconds in <receiver> weeks
# File lib/symphony/metronome/mixins.rb, line 74 def weeks return TimeFunctions.calculate_seconds( self, :weeks ) end
Returns the number of seconds in <receiver> years (approximate)
# File lib/symphony/metronome/mixins.rb, line 92 def years return TimeFunctions.calculate_seconds( self, :years ) end