Class

ActiveSupport::Duration

Inheritance
< ActiveSupport::BasicObject < ::BasicObject

Provides accurate date and time measurements using Date#advance and Time#advance, respectively. It mainly supports the methods on Numeric, such as in this example:

  1.month.ago       # equivalent to Time.now.advance(:months => -1)

Attributes

Name Visibility R/W Description
parts public RW
value public RW

Methods

Instance

Visibility Signature
public + (other)
public - (other)
public == (other)
public ago (time = ::Time.current)
public from_now (time = ::Time.current)
public since (time = ::Time.current)
public until (time = ::Time.current)

Instance Method Detail

+(other)

Adds another Duration or a Numeric to this Duration. Numeric values are treated as seconds.

-(other)

Subtracts another Duration or a Numeric from this Duration. Numeric values are treated as seconds.

==(other)

Returns true if other is also a Duration instance with the same value, or if other == value.

ago(time = ::Time.current)

Calculates a new Time or Date that is as far in the past as this Duration represents.

from_now(time = ::Time.current)

Alias for since

since(time = ::Time.current)

Calculates a new Time or Date that is as far in the future as this Duration represents.

until(time = ::Time.current)

Alias for ago