Class: SitemapGenerator::Numeric
- Inherits:
-
Object
- Object
- SitemapGenerator::Numeric
- Defined in:
- lib/sitemap_generator/core_ext/numeric.rb
Overview
Scoped Numeric wrapper providing byte-unit helpers (+kilobytes+, megabytes, etc.).
Defined here rather than reopening the global Numeric class.
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)
- #gigabytes ⇒ Object (also: #gigabyte)
-
#initialize(number) ⇒ Numeric
constructor
A new instance of Numeric.
- #kilobytes ⇒ Object (also: #kilobyte)
- #megabytes ⇒ Object (also: #megabyte)
- #petabytes ⇒ Object (also: #petabyte)
- #terabytes ⇒ Object (also: #terabyte)
Constructor Details
#initialize(number) ⇒ Numeric
Returns a new instance of Numeric.
14 15 16 |
# File 'lib/sitemap_generator/core_ext/numeric.rb', line 14 def initialize(number) @number = number end |
Instance Method Details
#bytes ⇒ Object Also known as: byte
Enables the use of byte calculations and declarations, like 45.bytes + 2.6.megabytes
19 20 21 |
# File 'lib/sitemap_generator/core_ext/numeric.rb', line 19 def bytes @number end |
#exabytes ⇒ Object Also known as: exabyte
49 50 51 |
# File 'lib/sitemap_generator/core_ext/numeric.rb', line 49 def exabytes @number * EXABYTE end |
#gigabytes ⇒ Object Also known as: gigabyte
34 35 36 |
# File 'lib/sitemap_generator/core_ext/numeric.rb', line 34 def gigabytes @number * GIGABYTE end |
#kilobytes ⇒ Object Also known as: kilobyte
24 25 26 |
# File 'lib/sitemap_generator/core_ext/numeric.rb', line 24 def kilobytes @number * KILOBYTE end |
#megabytes ⇒ Object Also known as: megabyte
29 30 31 |
# File 'lib/sitemap_generator/core_ext/numeric.rb', line 29 def megabytes @number * MEGABYTE end |
#petabytes ⇒ Object Also known as: petabyte
44 45 46 |
# File 'lib/sitemap_generator/core_ext/numeric.rb', line 44 def petabytes @number * PETABYTE end |
#terabytes ⇒ Object Also known as: terabyte
39 40 41 |
# File 'lib/sitemap_generator/core_ext/numeric.rb', line 39 def terabytes @number * TERABYTE end |