This is the development version of Kanrisuru. Since this is still a pre-1.0 release, we don't recommend using this in system-critical production environments.

Kanrisuru

Bits

The bits utility class helps with translating between various units, like kilobits, gigabytes and everything in between.

Public Class Methods

convert_from_kb

Converts a given value in kilobytes, into the metric given as the second argument.

Kanrisuru::Util::Bits.convert_from_kb(1000, 'mb')
1.0

convert_from_mb

Converts a given value in megabytes, into the metric given as the second argument.

Kanrisuru::Util::Bits.convert_from_mb(1, 'kilobyte')
1000.0

convert_from_gb

Converts a given value in gigabytes, into the metric given as the second argument.

Kanrisuru::Util::Bits.convert_from_gb(8000, 'terabit')
64.0

convert_from_tb

Converts a given value in terabytes, into the metric given as the second argument.

Kanrisuru::Util::Bits.convert_from_tb(10, 'gigabyte')
10,000.0

convert_from_pb

Converts a given value in petabytes, into the metric given as the second argument.

Kanrisuru::Util::Bits.convert_from_pb(0.0000091, 'mb')
9100.0

convert_bytes

Converts a given value from one digital prefix into another.

Kanrisuru::Util::Bits.convert_bytes(8, :bit, :byte)
1.0

Kanrisuru::Util::Bits.convert_bytes(1, :pb, :tb)
1000.0

convert_power

Finds the exponetial power conversion factor from one digital prefix to another.

Kanrisuru::Util::Bits.convert_power(:deca, :deca)
0

Kanrisuru::Util::Bits.convert_power(:giga, :kilo)
2