Module: PgExport::Dump::SizeHuman

Included in:
Base
Defined in:
lib/pg_export/entities/dump/size_human.rb

Instance Method Summary collapse

Instance Method Details

#size_humanObject



4
5
6
7
8
9
10
11
12
# File 'lib/pg_export/entities/dump/size_human.rb', line 4

def size_human
  {
    'B'  => 1024,
    'kB' => 1024 * 1024,
    'MB' => 1024 * 1024 * 1024,
    'GB' => 1024 * 1024 * 1024 * 1024,
    'TB' => 1024 * 1024 * 1024 * 1024 * 1024
  }.each_pair { |e, s| return "#{(size.to_f / (s / 1024)).round(2)}#{e}" if size < s }
end