Sha256: f8dd412c845bd1429577e6b178c1fe88f005a5fb001d392cb6b59f76c612acb1

Contents?: true

Size: 629 Bytes

Versions: 1

Compression:

Stored size: 629 Bytes

Contents

module Humanize
  module Bytes
    class Giga
      def initialize(value)
        @value = value
      end

      def value
        @value
      end

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

      def to_k
        Kilo.new @value * 1024 * 1024
      end

      def to_m
        Mega.new @value * 1024
      end

      def to_g
        self
      end

      def to_s
        @value.instance_of?(Float) ? formatted_float + ' giga bytes' : @value.to_s + ' giga 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/gbyte.rb