Module | Ramaze::CoreExtensions::Numeric
In: | lib/ramaze/snippets/numeric/filesize_format.rb lib/ramaze/snippets/numeric/time.rb

Extensions for Numeric

### Methods

ago before day days filesize_format from_now hour hours minute minutes month months second seconds since week weeks year years

### Constants

FILESIZE_FORMAT | = | [ ['%.1fT', 1 << 40], ['%.1fG', 1 << 30], ['%.1fM', 1 << 20], ['%.1fK', 1 << 10], ]

### Public Instance methods

ago(t = Time.now)

Time in the past, i.e. 3.days.ago

before(t = Time.now)

Alias for ago

day()

Alias for days

days()

24 hours in a day

filesize_format()

Output this number as easily readable filesize. Usage:

      100_000.filesize_format             # => "97.7K"
      100_000_000.filesize_format         # => "95.4M"
      100_000_000_000.filesize_format     # => "93.1G"
      100_000_000_000_000.filesize_format # => "90.9T"

from_now(t = Time.now)

Time in the future, i.e. 3.days.from_now

hour()

Alias for hours

hours()

60 minutes in an hour

minute()

Alias for minutes

minutes()

60 seconds in a minute

month()

Alias for months

months()

30 days in a month

second()

Alias for seconds

seconds()
since(t = Time.now)

Alias for from_now

week()

Alias for weeks

weeks()

7 days in a week

year()

Alias for years

years()

365.25 days in a year

[Validate]