Sha256: e553a768b4fcbf76d26cc17efd4acb7cb3f6a4d495097026b60fd372d9cdeb83

Contents?: true

Size: 565 Bytes

Versions: 1

Compression:

Stored size: 565 Bytes

Contents

require "humanize-bytes/version"

module Humanize
  module Bytes
    autoload :Byte, 'humanize-bytes/byte'
    autoload :Kilo, 'humanize-bytes/kbyte'
    autoload :Mega, 'humanize-bytes/mbyte'
    autoload :Giga, 'humanize-bytes/gbyte'

    def self.initialize(value, unit = 'b')
      case unit.to_s
        when 'b' then Humanize::Bytes::Byte.new(value)
        when 'k' then Humanize::Bytes::Kilo.new(value)
        when 'm' then Humanize::Bytes::Mega.new(value)
        when 'g' then Humanize::Bytes::Giga.new(value)
        else nil
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
humanize-bytes-1.0.0 lib/humanize-bytes.rb