Sha256: 3bf956b9abef8e38df5d6e66bfdf8878a9ad6bf55655da5012a72dbf396ed7bb
Contents?: true
Size: 619 Bytes
Versions: 1
Compression:
Stored size: 619 Bytes
Contents
module Humanize module Bytes class Kilo def initialize(value) @value = value end def value @value end def to_b Byte.new @value * 1024 end def to_k self end def to_m Mega.new @value / 1024.0 end def to_g Giga.new @value / 1024.0 / 1024 end def to_s @value.instance_of?(Float) ? formatted_float + ' kilo bytes' : @value.to_s + ' kilo bytes' end protected def formatted_float @value.to_s[0 .. @value.to_s.index('.') + 2] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
humanize-bytes-1.0.0 | lib/humanize-bytes/kbyte.rb |