struct

Number

Inherits AliasMethod < Comparable < Steppable < Comparable < Value < Object

The top-level number type.

Constants

EXABYTE = PETABYTE * 1024
GIGABYTE = MEGABYTE * 1024
KILOBYTE = 1024.to_big_i
MEGABYTE = KILOBYTE * 1024
PETABYTE = TERABYTE * 1024
TERABYTE = GIGABYTE * 1024

Instance methods

blank?

A number object will be blank if it's zero.

0.blank?
=> true

23.45.blank?
=> false

source: Rails ActiveSupport

Source
byte(*args)
Source
bytes

Enables the use of byte calculations and declarations, like 45.bytes + 2.6.megabytes

  2.bytes # => 2
Source
exabyte(*args)
Source
exabytes

Returns the number of bytes equivalent to the exabytes provided.

  2.exabytes # => 2_305_843_009_213_693_952
Source
gigabyte(*args)
Source
gigabytes

Returns the number of bytes equivalent to the gigabytes provided.

  2.gigabytes # => 2_147_483_648
Source
kilobyte(*args)
Source
kilobytes

Returns the number of bytes equivalent to the kilobytes provided.

  2.kilobytes # => 2048
Source
megabyte(*args)
Source
megabytes

Returns the number of bytes equivalent to the megabytes provided.

  2.megabytes # => 2_097_152
Source
petabyte(*args)
Source
petabytes

Returns the number of bytes equivalent to the petabytes provided.

  2.petabytes # => 2_251_799_813_685_248
Source
terabyte(*args)
Source
terabytes

Returns the number of bytes equivalent to the terabytes provided.

  2.terabytes # => 2_199_023_255_552
Source