Class: Expire::Commands::Remove

Inherits:
Expire::Command show all
Defined in:
lib/expire/commands/remove.rb

Overview

Remove files and directories

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Expire::Command

#command, #cursor, #editor, #exec_exist?, #generator, #pager, #platform, #prompt, #screen, #which

Constructor Details

#initialize(path:) ⇒ Remove

Returns a new instance of Remove.



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

def initialize(path:)
  @path = path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



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

def path
  @path
end

Instance Method Details

#execute(output: $stdout) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/expire/commands/remove.rb', line 15

def execute(output: $stdout)
  begin
    Expire.remove(path)
  rescue Errno::ENOENT => e
    output.puts "can't remove #{path}: #{e}"
    exit 1
  end
  output.puts "removed #{path}"
end