Class: Jah::Disk
Constant Summary
Constants included from Command
Instance Attribute Summary collapse
-
#free ⇒ Object
readonly
Returns the value of attribute free.
-
#mount ⇒ Object
readonly
Returns the value of attribute mount.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#percent ⇒ Object
readonly
Returns the value of attribute percent.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
-
#used ⇒ Object
readonly
Returns the value of attribute used.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(args) ⇒ Disk
constructor
A new instance of Disk.
Methods included from Command
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
#free ⇒ Object (readonly)
Returns the value of attribute free.
5 6 7 |
# File 'lib/jah/commands/disk.rb', line 5 def free @free end |
#mount ⇒ Object (readonly)
Returns the value of attribute mount.
5 6 7 |
# File 'lib/jah/commands/disk.rb', line 5 def mount @mount end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/jah/commands/disk.rb', line 5 def path @path end |
#percent ⇒ Object (readonly)
Returns the value of attribute percent.
5 6 7 |
# File 'lib/jah/commands/disk.rb', line 5 def percent @percent end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
5 6 7 |
# File 'lib/jah/commands/disk.rb', line 5 def total @total end |
#used ⇒ Object (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
.all ⇒ Object
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 |
.mount ⇒ Object
26 27 |
# File 'lib/jah/commands/disk.rb', line 26 def self.mount end |
.read ⇒ Object
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 |
.umount ⇒ Object
29 30 |
# File 'lib/jah/commands/disk.rb', line 29 def self.umount end |