Class: SimpleGdrive::Cleaner

Inherits:
Base
  • Object
show all
Defined in:
lib/simple_gdrive/cleaner.rb

Overview

Cleans the directory Returns array of removed file names

Instance Method Summary collapse

Constructor Details

#initialize(base_folder_id:, move_to_trash: false) ⇒ Cleaner

Returns a new instance of Cleaner.



5
6
7
8
# File 'lib/simple_gdrive/cleaner.rb', line 5

def initialize(base_folder_id:, move_to_trash: false)
  @base_folder_id = base_folder_id
  @move_to_trash = move_to_trash
end

Instance Method Details

#callObject



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/simple_gdrive/cleaner.rb', line 10

def call
  @page_token = nil
  @files_to_remove = {}

  loop do
    fetch_batch
    break if @page_token.nil?
  end

  remove_files

  @files_to_remove.values
end