Class: Jah::Disk

Inherits:
Object
  • Object
show all
Includes:
Command
Defined in:
lib/jah/commands/disk.rb

Constant Summary

Constants included from Command

Command::COMM

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Command

find, included

Constructor Details

#initialize(args) ⇒ Disk

Returns a new instance of Disk.



20
21
22
23
24
# File 'lib/jah/commands/disk.rb', line 20

def initialize(args)
  @path, @total, @used, @free, @percent, @mount = args
  @total, @used, @free = [@total, @used, @free].map(&:to_i)
  @percent = @percent[0..-2].to_i
end

Instance Attribute Details

#freeObject (readonly)

Returns the value of attribute free.



5
6
7
# File 'lib/jah/commands/disk.rb', line 5

def free
  @free
end

#mountObject (readonly)

Returns the value of attribute mount.



5
6
7
# File 'lib/jah/commands/disk.rb', line 5

def mount
  @mount
end

#pathObject (readonly)

Returns the value of attribute path.



5
6
7
# File 'lib/jah/commands/disk.rb', line 5

def path
  @path
end

#percentObject (readonly)

Returns the value of attribute percent.



5
6
7
# File 'lib/jah/commands/disk.rb', line 5

def percent
  @percent
end

#totalObject (readonly)

Returns the value of attribute total.



5
6
7
# File 'lib/jah/commands/disk.rb', line 5

def total
  @total
end

#usedObject (readonly)

Returns the value of attribute used.



5
6
7
# File 'lib/jah/commands/disk.rb', line 5

def used
  @used
end

Class Method Details

.allObject



14
15
16
17
18
# File 'lib/jah/commands/disk.rb', line 14

def self.all
  @disks = `df`.to_a.reject { |dl| dl =~ /Size|Use|none/ }.map do |l|
    new l.split(" ")
  end
end

.mountObject



26
27
# File 'lib/jah/commands/disk.rb', line 26

def self.mount
end

.readObject



8
9
10
11
12
# File 'lib/jah/commands/disk.rb', line 8

def self.read
  all.map do |d|
    "\n*#{d[:path]}* => #{d[:percent]}"
  end.join("\n")
end

.umountObject



29
30
# File 'lib/jah/commands/disk.rb', line 29

def self.umount
end