Sha256: 5d583a7380d6fbf94223012eff248aa28640a55b0e3e4e300562d6fbab3f2e88

Contents?: true

Size: 455 Bytes

Versions: 1

Compression:

Stored size: 455 Bytes

Contents

module Humanize
  class Mega
    def initialize(value)
      @value = value
    end

    def value
      @value
    end

    def to_b
      Byte.new @value * 1024 * 1024
    end

    def to_k
      Kilo.new @value * 1024
    end

    def to_m
      self
    end

    def to_g
      Giga.new @value / 1024.0
    end

    def to_s(options = {})
      size = options.fetch(:decimal_digits, value.to_s.size)
      ("%.#{size}f" % value).to_f
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
humanize-bytes-2.0.0 lib/humanize/mega.rb