Class: Commands::Remove

Inherits:
Command show all
Defined in:
lib/gdsh/remove.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DriveError

#drive_error_string

Methods included from CommandMixin

included

Constructor Details

#initialize(client, params) ⇒ Remove

Returns a new instance of Remove.



17
18
19
20
# File 'lib/gdsh/remove.rb', line 17

def initialize(client, params)
  super(client, params)
  @file_id = @params[1]
end

Class Method Details

.command_nameObject



5
6
7
# File 'lib/gdsh/remove.rb', line 5

def self.command_name
  'rm'
end

.functionObject



13
14
15
# File 'lib/gdsh/remove.rb', line 13

def self.function
  'Removes the file.'
end

.parametersObject



9
10
11
# File 'lib/gdsh/remove.rb', line 9

def self.parameters
  '(<file_id>)'
end

Instance Method Details

#executeObject



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/gdsh/remove.rb', line 22

def execute
  drive = @client.discovered_api('drive', 'v2')
  result = @client.execute(
    api_method: drive.files.trash,
    parameters: { fileId: @file_id })
  if result.status != 200
    puts drive_error_string
  else
    puts 'Deleted.'.colorize(:green)
  end
end