Skip to Content Skip to Search

class Numeric

Constants

PETABYTE * 1024
MEGABYTE * 1024
1024
KILOBYTE * 1024
TERABYTE * 1024
GIGABYTE * 1024
EXABYTE * 1024

Public instance methods

Alias for: bytes.

Also aliased as: byte.

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

2.bytes # => 2
Source code GitHub
# File activesupport/lib/active_support/core_ext/numeric/bytes.rb, line 15
def bytes
  self
end

Alias for: exabytes.

Also aliased as: exabyte.

Returns the number of bytes equivalent to the exabytes provided.

2.exabytes # => 2_305_843_009_213_693_952
Source code GitHub
# File activesupport/lib/active_support/core_ext/numeric/bytes.rb, line 63
def exabytes
  self * EXABYTE
end

Alias for: gigabytes.

Also aliased as: gigabyte.

Returns the number of bytes equivalent to the gigabytes provided.

2.gigabytes # => 2_147_483_648
Source code GitHub
# File activesupport/lib/active_support/core_ext/numeric/bytes.rb, line 39
def gigabytes
  self * GIGABYTE
end
Source code GitHub
# File activesupport/lib/active_support/core_ext/string/output_safety.rb, line 13
def html_safe?
  true
end

Alias for: kilobytes.

Also aliased as: kilobyte.

Returns the number of bytes equivalent to the kilobytes provided.

2.kilobytes # => 2048
Source code GitHub
# File activesupport/lib/active_support/core_ext/numeric/bytes.rb, line 23
def kilobytes
  self * KILOBYTE
end

Alias for: megabytes.

Also aliased as: megabyte.

Returns the number of bytes equivalent to the megabytes provided.

2.megabytes # => 2_097_152
Source code GitHub
# File activesupport/lib/active_support/core_ext/numeric/bytes.rb, line 31
def megabytes
  self * MEGABYTE
end

Alias for: petabytes.

Also aliased as: petabyte.

Returns the number of bytes equivalent to the petabytes provided.

2.petabytes # => 2_251_799_813_685_248
Source code GitHub
# File activesupport/lib/active_support/core_ext/numeric/bytes.rb, line 55
def petabytes
  self * PETABYTE
end

Alias for: terabytes.

Also aliased as: terabyte.

Returns the number of bytes equivalent to the terabytes provided.

2.terabytes # => 2_199_023_255_552
Source code GitHub
# File activesupport/lib/active_support/core_ext/numeric/bytes.rb, line 47
def terabytes
  self * TERABYTE
end

Alias for: zettabytes.

Also aliased as: zettabyte.

Returns the number of bytes equivalent to the zettabytes provided.

2.zettabytes # => 2_361_183_241_434_822_606_848
Source code GitHub
# File activesupport/lib/active_support/core_ext/numeric/bytes.rb, line 71
def zettabytes
  self * ZETTABYTE
end

Definition files