Symphony::Metronome::

TimeRefinements module

Refinements to Numeric to add time-related convenience methods

Public Instance Methods

after( time )

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
ago()

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
before( time )

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
days()

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
fortnights()

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
from_now()

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
hours()

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
minutes()

Returns number of seconds in <receiver> minutes

# File lib/symphony/metronome/mixins.rb, line 56
def minutes
        return TimeFunctions.calculate_seconds( self, :minutes )
end
months()

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
seconds()

Number of seconds (returns receiver unmodified)

# File lib/symphony/metronome/mixins.rb, line 50
def seconds
        return self
end
weeks()

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
years()

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