Sha256: 6a12eacd6a16cd31b9e9121caade0e94acb86a34e75e52ad868f131c11a50f1e

Contents?: true

Size: 604 Bytes

Versions: 2

Compression:

Stored size: 604 Bytes

Contents

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

      def value
        @value
      end

      def to_b
        @value * 1024 * 1024 * 1024
      end

      def to_k
        @value * 1024 * 1024
      end

      def to_m
        @value * 1024
      end

      def to_g
        @value
      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

2 entries across 2 versions & 1 rubygems

Version Path
humanize-bytes-0.1.0 lib/humanize-bytes/gbyte.rb
humanize-bytes-0.0.2 lib/humanize-bytes/gbyte.rb