Method: Wdmc::Device#usage

Defined in:
lib/wdmc/device.rb

#usageObject



57
58
59
60
61
62
63
64
65
66
67
# File 'lib/wdmc/device.rb', line 57

def usage
  usage = @wdmc.storage_usage
  free = usage[:size].to_i - usage[:usage].to_i
  puts "Device Usage".upcase.color(:magenta)
  puts "\sCapacity\t\t: ".color(:whitesmoke) + Filesize.from("#{usage[:size]} B").to_s('GB')
  puts "\sFree\t\t\t: ".color(:whitesmoke) + Filesize.from("#{free} B").to_s('GB')
  puts "\sUsage\t\t\t: ".color(:whitesmoke) + Filesize.from("#{usage[:usage]} B").to_s('GB')
  puts "\s\s- Videos\t\t: ".color(:whitesmoke) + Filesize.from("#{usage[:video]} B").to_s('GB') if usage[:video].to_i > 0
  puts "\s\s- Photos\t\t: ".color(:whitesmoke) + Filesize.from("#{usage[:photo]} B").to_s('GB') if usage[:photo].to_i > 0
  puts "\s\s- Music\t\t: ".color(:whitesmoke) + Filesize.from("#{usage[:music]} B").to_s('GB') if usage[:music].to_i > 0
end