class DuPretty::Prettier
Public Class Methods
new(path, min_kbyte: 0, depth: nil, with_files: false)
click to toggle source
# File lib/du_pretty/prettier.rb, line 6 def initialize(path, min_kbyte: 0, depth: nil, with_files: false) @path = File.expand_path(path, Pathname.pwd) @min_kbyte = min_kbyte @depth = depth @with_files = with_files end
Public Instance Methods
original()
click to toggle source
# File lib/du_pretty/prettier.rb, line 13 def original filtered_disk_usages.map(&:pretty).join("\n") end
sorted()
click to toggle source
# File lib/du_pretty/prettier.rb, line 17 def sorted filtered_disk_usages.sort_by(&:kbyte).map(&:pretty).join("\n") end
tree()
click to toggle source
# File lib/du_pretty/prettier.rb, line 21 def tree filtered_disk_usages.reverse.map(&:tree_format).join("\n") end
Private Instance Methods
disk_usages()
click to toggle source
# File lib/du_pretty/prettier.rb, line 36 def disk_usages xs = du.split("\n").map { |line| DiskUsage.new(line, @path) } total = xs.map(&:kbyte).max xs.map { |x| DiskUsage.new(x.raw, @path, total: total) } end
du()
click to toggle source
# File lib/du_pretty/prettier.rb, line 27 def du options = [ @depth.nil? ? nil : "-d #{@depth}", @with_files ? '-a' : nil, '-k' ] `du #{options.join(' ')} #{@path.gsub(' ', '\ ')}` end
filtered_disk_usages()
click to toggle source
# File lib/du_pretty/prettier.rb, line 42 def filtered_disk_usages disk_usages.select { |x| x.kbyte >= @min_kbyte } end