Class: Numeric
- Inherits:
-
Object
- Object
- Numeric
- Defined in:
- lib/core_ext/numeric_bytes.rb
Constant Summary collapse
- KILOBYTE =
1024- MEGABYTE =
KILOBYTE * 1024
- GIGABYTE =
MEGABYTE * 1024
- TERABYTE =
GIGABYTE * 1024
- PETABYTE =
TERABYTE * 1024
- EXABYTE =
PETABYTE * 1024
Instance Method Summary collapse
-
#bytes ⇒ Object
(also: #byte)
Enables the use of byte calculations and declarations, like 45.bytes + 2.6.megabytes.
-
#exabytes ⇒ Object
(also: #exabyte)
Returns the number of bytes equivalent to the exabytes provided.
-
#gigabytes ⇒ Object
(also: #gigabyte)
Returns the number of bytes equivalent to the gigabytes provided.
-
#kilobytes ⇒ Object
(also: #kilobyte)
Returns the number of bytes equivalent to the kilobytes provided.
-
#megabytes ⇒ Object
(also: #megabyte)
Returns the number of bytes equivalent to the megabytes provided.
-
#petabytes ⇒ Object
(also: #petabyte)
Returns the number of bytes equivalent to the petabytes provided.
-
#terabytes ⇒ Object
(also: #terabyte)
Returns the number of bytes equivalent to the terabytes provided.
Instance Method Details
#bytes ⇒ Object Also known as: byte
Enables the use of byte calculations and declarations, like 45.bytes + 2.6.megabytes
2.bytes # => 2
40 41 42 |
# File 'lib/core_ext/numeric_bytes.rb', line 40 def bytes self end |
#exabytes ⇒ Object Also known as: exabyte
Returns the number of bytes equivalent to the exabytes provided.
2.exabytes # => 2_305_843_009_213_693_952
88 89 90 |
# File 'lib/core_ext/numeric_bytes.rb', line 88 def exabytes self * EXABYTE end |
#gigabytes ⇒ Object Also known as: gigabyte
Returns the number of bytes equivalent to the gigabytes provided.
2.gigabytes # => 2_147_483_648
64 65 66 |
# File 'lib/core_ext/numeric_bytes.rb', line 64 def gigabytes self * GIGABYTE end |
#kilobytes ⇒ Object Also known as: kilobyte
Returns the number of bytes equivalent to the kilobytes provided.
2.kilobytes # => 2048
48 49 50 |
# File 'lib/core_ext/numeric_bytes.rb', line 48 def kilobytes self * KILOBYTE end |
#megabytes ⇒ Object Also known as: megabyte
Returns the number of bytes equivalent to the megabytes provided.
2.megabytes # => 2_097_152
56 57 58 |
# File 'lib/core_ext/numeric_bytes.rb', line 56 def megabytes self * MEGABYTE end |
#petabytes ⇒ Object Also known as: petabyte
Returns the number of bytes equivalent to the petabytes provided.
2.petabytes # => 2_251_799_813_685_248
80 81 82 |
# File 'lib/core_ext/numeric_bytes.rb', line 80 def petabytes self * PETABYTE end |
#terabytes ⇒ Object Also known as: terabyte
Returns the number of bytes equivalent to the terabytes provided.
2.terabytes # => 2_199_023_255_552
72 73 74 |
# File 'lib/core_ext/numeric_bytes.rb', line 72 def terabytes self * TERABYTE end |