Class Numeric
In: lib/facet/bytes.rb
lib/facet/times.rb
Parent: Object

Additions to Numeric class

Methods

after   ago   before   bits_to_bytes   byte   bytes   day   days   fortnight   fortnights   from_now   gb   gigabyte   gigabytes   hour   hours   kb   kilobyte   kilobytes   later   mb   megabyte   megabytes   microsecond   microseconds   millisecond   milliseconds   minute   minutes   month   months   second   seconds   since   tb   terabyte   terabytes   until   week   weeks   year   years  

Public Instance methods

Calculates time after a given time. Default time is now. Reads best with argument: 10.minutes.after(time)

ago(time = ::Time.now)

Alias for before

Calculates time before a given time. Default time is now. Reads best with arguments: 10.days.before( Time.now - 1.day )

Converts bits to bytes.

byte()

Alias for bytes

Enables the use of byte calculations and declarations, like 45.bytes + 2.6.megabytes. The base unit for all of these Numeric bytes methods is bytes. (One might expect it to be bits, but that doesn’t seem to be the general consensus.)

day()

Alias for days

Converts days into seconds.

fortnight()

Alias for fortnights

Converts fortnights into seconds. (A fortnight is 2 weeks)

from_now(time = ::Time.now)

Alias for after

gb()

Alias for gigabytes

gigabyte()

Alias for gigabytes

Converts gigabytes to bytes.

hour()

Alias for hours

Converts hours into seconds.

kb()

Alias for kilobytes

kilobyte()

Alias for kilobytes

Converts kilobytes to bytes.

later(time = ::Time.now)

Alias for after

mb()

Alias for megabytes

megabyte()

Alias for megabytes

Converts megabytes to bytes.

microsecond()

Alias for microseconds

Converts microseconds into a fraction of seconds.

millisecond()

Alias for milliseconds

Converts milliseconds into a fraction of seconds.

minute()

Alias for minutes

Converts minutes into seconds.

month()

Alias for months

Converts months into seconds. WARNING: This is not exact as it assumes 30 days to a month.

second()

Alias for seconds

Enables the use of time calculations and declarations, like 45.minutes + 2.hours + 4.years. The base unit for all of these Numeric time methods is seconds.

since(time = ::Time.now)

Alias for after

tb()

Alias for terabytes

terabyte()

Alias for terabytes

Converts terabytes to bytes.

until(time = ::Time.now)

Alias for before

week()

Alias for weeks

Converts weeks into seconds.

year()

Alias for years

Converts years into seconds.

[Validate]