Sha256: b385823ab133fa84e52203a53f71c781882a54f061d670b9a5b7958eef1138c0
Contents?: true
Size: 924 Bytes
Versions: 10
Compression:
Stored size: 924 Bytes
Contents
class ByteNumber < Numeric def initialize(int) @int = int end def to_s @int.to_s end def to_i @int end def to_f @int.to_f end def to_B to_i end def to_KB _compute_unit_to_n_kilo(1) end def to_MB _compute_unit_to_n_kilo(2) end def to_GB _compute_unit_to_n_kilo(3) end def coerce(other) to_i.coerce(other) end def <=>(other) to_i <=> other end def +(other) to_i + other end def -(other) to_i - other end def *(other) to_i * other end def /(other) to_i / other end def pow(n) self.class.new(to_i ** n) end def self.from_GB(value) self.new(value*(1024**3)) end private def _compute_unit_to_n_kilo(n=0) (to_f/(1024 ** n)).ceil end end
Version data entries
10 entries across 10 versions & 1 rubygems