Class: Numeric

Inherits:
Object
  • Object
show all
Defined in:
lib/windows/sys/filesystem.rb,
lib/unix/sys/filesystem.rb

Overview

Some convenient methods for converting bytes to kb, mb, and gb.

Instance Method Summary collapse

Instance Method Details

#to_gbObject

call-seq:

<tt>num</tt>.to_gb

Returns num in terms of gigabytes.



583
584
585
# File 'lib/unix/sys/filesystem.rb', line 583

def to_gb
  self / 1073741824
end

#to_kbObject

call-seq:

<tt>num</tt>.to_kb

Returns num in terms of kilobytes.



573
574
575
# File 'lib/unix/sys/filesystem.rb', line 573

def to_kb
  self / 1024
end

#to_mbObject

call-seq:

<tt>num</tt>.to_mb

Returns num in terms of megabytes.



578
579
580
# File 'lib/unix/sys/filesystem.rb', line 578

def to_mb
  self / 1048576
end

#to_tbObject

call-seq:

<tt>num</tt>.to_gb

Returns num in terms of terabytes.



588
589
590
# File 'lib/unix/sys/filesystem.rb', line 588

def to_tb
  self / 1099511627776
end