класс ActiveSupport::Duration
Обеспечивает точные измерения дат и времени, используя Date#advance и Time#advance соответственно. В основном поддерживает методы в Numeric.
1.month.ago # equivalent to Time.now.advance(months: -1)
Атрибуты
parts[RW]
value[RW]
Публичные методы экземпляров
Добавляет другой Duration или Numeric к этому Duration. Значения Numeric рассматриваются как секунды.
# File activesupport/lib/active_support/duration.rb, line 19
def +(other)
if Duration === other
Duration.new(value + other.value, @parts + other.parts)
else
Duration.new(value + other, @parts + [[:seconds, other]])
end
end Возвращает true если other также является экземпляром Duration с такими же value, или если other == value.
# File activesupport/lib/active_support/duration.rb, line 44
def ==(other)
if Duration === other
other.value == value
else
other == value
end
end # File activesupport/lib/active_support/duration.rb, line 52 def eql?(other) other.is_a?(Duration) && self == other end
from_now(time = ::Time.current)
Псевдоним для: since
until(time = ::Time.current)
Псевдоним для: ago
© 2004–2016 David Heinemeier Hansson
Licensed under the MIT License.