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
byte(*args)
Sourcebytes
Enables the use of byte calculations and declarations, like 45.bytes + 2.6.megabytes
2.bytes # => 2
exabyte(*args)
Sourceexabytes
Returns the number of bytes equivalent to the exabytes provided.
2.exabytes # => 2_305_843_009_213_693_952
gigabyte(*args)
Sourcegigabytes
Returns the number of bytes equivalent to the gigabytes provided.
2.gigabytes # => 2_147_483_648
kilobyte(*args)
Sourcekilobytes
Returns the number of bytes equivalent to the kilobytes provided.
2.kilobytes # => 2048
megabyte(*args)
Sourcemegabytes
Returns the number of bytes equivalent to the megabytes provided.
2.megabytes # => 2_097_152
petabyte(*args)
Sourcepetabytes
Returns the number of bytes equivalent to the petabytes provided.
2.petabytes # => 2_251_799_813_685_248
terabyte(*args)
Sourceterabytes
Returns the number of bytes equivalent to the terabytes provided.
2.terabytes # => 2_199_023_255_552