Sha256: 8919454f9012ae4e1db92b5148dd501ca47f5769fbda5715c01b8bd303df2ab3
Contents?: true
Size: 594 Bytes
Versions: 2
Compression:
Stored size: 594 Bytes
Contents
module Humanize module Bytes class Kilo def initialize(value) @value = value end def value @value end def to_b @value * 1024 end def to_k @value end def to_m @value / 1024.0 end def to_g @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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
humanize-bytes-0.1.0 | lib/humanize-bytes/kbyte.rb |
humanize-bytes-0.0.2 | lib/humanize-bytes/kbyte.rb |