class Numeric

Requiring bytesize/units adds convenience methods to Numeric for easy creation of ByteSize and IECByteSize values.

Examples of use

require 'bytesize/units'

1.21.gib       #=> (1.21 GiB)

3.tb           #=> (3 TB)

100.gb         #=> (100 GB)

42.gib.to_mib  #=> 43008.0

22.gib.to_si   #=> (23.62 GB)

16.gb.to_iec   #=> (14.9 GiB)

Public Instance Methods

bytes → bytesize click to toggle source

Returns a new instance of ByteSize representing self number of bytes.

# File lib/bytesize/units.rb, line 67
        
eb → bytesize click to toggle source

Returns a new instance of ByteSize representing self number of exabytes.

# File lib/bytesize/units.rb, line 127
        
eib → bytesize click to toggle source

Returns a new instance of IECByteSize representing self number of exbibytes.

# File lib/bytesize/units.rb, line 207
        
gb → bytesize click to toggle source

Returns a new instance of ByteSize representing self number of gigabytes.

# File lib/bytesize/units.rb, line 97
        
gib → bytesize click to toggle source

Returns a new instance of IECByteSize representing self number of gibibytes.

# File lib/bytesize/units.rb, line 177
        
kb → bytesize click to toggle source

Returns a new instance of ByteSize representing self number of kilobytes.

# File lib/bytesize/units.rb, line 77
        
kib → bytesize click to toggle source

Returns a new instance of IECByteSize representing self number of kibibytes.

# File lib/bytesize/units.rb, line 157
        
mb → bytesize click to toggle source

Returns a new instance of ByteSize representing self number of megabytes.

# File lib/bytesize/units.rb, line 87
        
mib → bytesize click to toggle source

Returns a new instance of IECByteSize representing self number of mebibytes.

# File lib/bytesize/units.rb, line 167
        
pb → bytesize click to toggle source

Returns a new instance of ByteSize representing self number of petabytes.

# File lib/bytesize/units.rb, line 117
        
pib → bytesize click to toggle source

Returns a new instance of IECByteSize representing self number of pebibytes.

# File lib/bytesize/units.rb, line 197
        
tb → bytesize click to toggle source

Returns a new instance of ByteSize representing self number of terabytes.

# File lib/bytesize/units.rb, line 107
        
tib → bytesize click to toggle source

Returns a new instance of IECByteSize representing self number of tebibytes.

# File lib/bytesize/units.rb, line 187
        
yb → bytesize click to toggle source

Returns a new instance of ByteSize representing self number of yottabytes.

# File lib/bytesize/units.rb, line 147
        
yib → bytesize click to toggle source

Returns a new instance of IECByteSize representing self number of yobibytes.

# File lib/bytesize/units.rb, line 227
zb → bytesize click to toggle source

Returns a new instance of ByteSize representing self number of zettabytes.

# File lib/bytesize/units.rb, line 137
        
zib → bytesize click to toggle source

Returns a new instance of IECByteSize representing self number of zebibytes.

# File lib/bytesize/units.rb, line 217