Sha256: 34c25790bb9c27a139fcc802bffdce0f78fa088eff76061bbfe3382a697af98f

Contents?: true

Size: 416 Bytes

Versions: 2

Compression:

Stored size: 416 Bytes

Contents

class PgExport
  module Roles
    module HumanReadable
      MAPPING = {
        'B'  => 1024,
        'kB' => 1024 * 1024,
        'MB' => 1024 * 1024 * 1024,
        'GB' => 1024 * 1024 * 1024 * 1024,
        'TB' => 1024 * 1024 * 1024 * 1024 * 1024
      }.freeze

      def size_human
        MAPPING.each_pair { |e, s| return "#{(size.to_f / (s / 1024)).round(2)}#{e}" if size < s }
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pg_export-0.6.1 lib/pg_export/roles/human_readable.rb
pg_export-0.6.0 lib/pg_export/roles/human_readable.rb