Class: UndriveGoogle::Actions::Sweep

Inherits:
Object
  • Object
show all
Defined in:
lib/undrive_google/actions/sweep.rb

Overview

Empty the directory before putting liberated files into it?

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSweep

Returns a new instance of Sweep.



9
10
11
# File 'lib/undrive_google/actions/sweep.rb', line 9

def initialize
  @dir = Options.instance.dir
end

Instance Attribute Details

#dirObject

Returns the value of attribute dir.



7
8
9
# File 'lib/undrive_google/actions/sweep.rb', line 7

def dir
  @dir
end

Instance Method Details

#sweep!Object



13
14
15
16
17
18
19
20
# File 'lib/undrive_google/actions/sweep.rb', line 13

def sweep!
  return if !dir || dir.length.zero? || dir == "/"
  return unless Dir.exist?(dir)
  return if Dir.empty?(dir)

  puts "Sweeping directory clean #{dir}" if Options.instance.verbose
  FileUtils.rm_rf Dir.glob("#{dir}/*")
end