class FreeDiskSpace

Attributes

dir[R]

Public Class Methods

bytes(dir) click to toggle source
# File lib/free_disk_space.rb, line 27
def self.bytes(dir)
  new(dir).bytes
end
gigabytes(dir) click to toggle source
# File lib/free_disk_space.rb, line 15
def self.gigabytes(dir)
  new(dir).gigabytes
end
kilobytes(dir) click to toggle source
# File lib/free_disk_space.rb, line 23
def self.kilobytes(dir)
  new(dir).kilobytes
end
megabytes(dir) click to toggle source
# File lib/free_disk_space.rb, line 19
def self.megabytes(dir)
  new(dir).megabytes
end
new(dir) click to toggle source
# File lib/free_disk_space.rb, line 7
def initialize(dir)
  @dir = dir
end
terabytes(dir) click to toggle source
# File lib/free_disk_space.rb, line 11
def self.terabytes(dir)
  new(dir).terabytes
end

Public Instance Methods

bytes() click to toggle source
# File lib/free_disk_space.rb, line 47
def bytes
  filesystem_stat.block_size * filesystem_stat.blocks_available
end
gigabytes() click to toggle source
# File lib/free_disk_space.rb, line 35
def gigabytes
  megabytes / 1024
end
kilobytes() click to toggle source
# File lib/free_disk_space.rb, line 43
def kilobytes
  bytes.to_f / 1024
end
megabytes() click to toggle source
# File lib/free_disk_space.rb, line 39
def megabytes
  kilobytes / 1024
end
terabytes() click to toggle source
# File lib/free_disk_space.rb, line 31
def terabytes
  gigabytes / 1024
end

Private Instance Methods

filesystem_stat() click to toggle source
# File lib/free_disk_space.rb, line 53
def filesystem_stat
  @filesystem_stat ||= Sys::Filesystem.stat(dir)
end