Class: Numeric

Inherits:
Object show all
Defined in:
lib/simple_ext/object/blank.rb,
lib/simple_ext/numeric/bytes.rb

Overview

:nodoc:

Constant Summary collapse

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

Instance Method Summary collapse

Instance Method Details

#blank?false

No number is blank:

1.blank? # => false
0.blank? # => false

Returns:

  • (false)


140
141
142
# File 'lib/simple_ext/object/blank.rb', line 140

def blank?
  false
end

#bytesObject Also known as: byte

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

2.bytes # => 2


14
15
16
# File 'lib/simple_ext/numeric/bytes.rb', line 14

def bytes
  self
end

#exabytesObject Also known as: exabyte

Returns the number of bytes equivalent to the exabytes provided.

2.exabytes # => 2_305_843_009_213_693_952


62
63
64
# File 'lib/simple_ext/numeric/bytes.rb', line 62

def exabytes
  self * EXABYTE
end

#gigabytesObject Also known as: gigabyte

Returns the number of bytes equivalent to the gigabytes provided.

2.gigabytes # => 2_147_483_648


38
39
40
# File 'lib/simple_ext/numeric/bytes.rb', line 38

def gigabytes
  self * GIGABYTE
end

#kilobytesObject Also known as: kilobyte

Returns the number of bytes equivalent to the kilobytes provided.

2.kilobytes # => 2048


22
23
24
# File 'lib/simple_ext/numeric/bytes.rb', line 22

def kilobytes
  self * KILOBYTE
end

#megabytesObject Also known as: megabyte

Returns the number of bytes equivalent to the megabytes provided.

2.megabytes # => 2_097_152


30
31
32
# File 'lib/simple_ext/numeric/bytes.rb', line 30

def megabytes
  self * MEGABYTE
end

#petabytesObject Also known as: petabyte

Returns the number of bytes equivalent to the petabytes provided.

2.petabytes # => 2_251_799_813_685_248


54
55
56
# File 'lib/simple_ext/numeric/bytes.rb', line 54

def petabytes
  self * PETABYTE
end

#terabytesObject Also known as: terabyte

Returns the number of bytes equivalent to the terabytes provided.

2.terabytes # => 2_199_023_255_552


46
47
48
# File 'lib/simple_ext/numeric/bytes.rb', line 46

def terabytes
  self * TERABYTE
end