Class: FreeDiskSpace

Inherits:
Object
  • Object
show all
Defined in:
lib/free_disk_space.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir) ⇒ FreeDiskSpace

Returns a new instance of FreeDiskSpace.



7
8
9
# File 'lib/free_disk_space.rb', line 7

def initialize(dir)
  @dir = dir
end

Instance Attribute Details

#dirObject (readonly)

Returns the value of attribute dir.



5
6
7
# File 'lib/free_disk_space.rb', line 5

def dir
  @dir
end

Class Method Details

.bytes(dir) ⇒ Object



27
28
29
# File 'lib/free_disk_space.rb', line 27

def self.bytes(dir)
  new(dir).bytes
end

.gigabytes(dir) ⇒ Object



15
16
17
# File 'lib/free_disk_space.rb', line 15

def self.gigabytes(dir)
  new(dir).gigabytes
end

.kilobytes(dir) ⇒ Object



23
24
25
# File 'lib/free_disk_space.rb', line 23

def self.kilobytes(dir)
  new(dir).kilobytes
end

.megabytes(dir) ⇒ Object



19
20
21
# File 'lib/free_disk_space.rb', line 19

def self.megabytes(dir)
  new(dir).megabytes
end

.terabytes(dir) ⇒ Object



11
12
13
# File 'lib/free_disk_space.rb', line 11

def self.terabytes(dir)
  new(dir).terabytes
end

Instance Method Details

#bytesObject



47
48
49
# File 'lib/free_disk_space.rb', line 47

def bytes
  filesystem_stat.block_size * filesystem_stat.blocks_available
end

#gigabytesObject



35
36
37
# File 'lib/free_disk_space.rb', line 35

def gigabytes
  megabytes / 1024
end

#kilobytesObject



43
44
45
# File 'lib/free_disk_space.rb', line 43

def kilobytes
  bytes.to_f / 1024
end

#megabytesObject



39
40
41
# File 'lib/free_disk_space.rb', line 39

def megabytes
  kilobytes / 1024
end

#terabytesObject



31
32
33
# File 'lib/free_disk_space.rb', line 31

def terabytes
  gigabytes / 1024
end