Class: Kward::SessionTrash
- Inherits:
-
Object
- Object
- Kward::SessionTrash
- Defined in:
- lib/kward/session_trash.rb
Overview
Best-effort session file remover. Uses the OS trash/recycle bin when a supported platform tool is available, and falls back to permanent deletion.
Instance Method Summary collapse
- #delete(path) ⇒ Object
-
#initialize(env: ENV, command_runner: nil, host_os: RbConfig::CONFIG["host_os"]) ⇒ SessionTrash
constructor
A new instance of SessionTrash.
Constructor Details
#initialize(env: ENV, command_runner: nil, host_os: RbConfig::CONFIG["host_os"]) ⇒ SessionTrash
Returns a new instance of SessionTrash.
8 9 10 11 12 |
# File 'lib/kward/session_trash.rb', line 8 def initialize(env: ENV, command_runner: nil, host_os: RbConfig::CONFIG["host_os"]) @env = env @command_runner = command_runner || method(:run_command) @host_os = host_os end |
Instance Method Details
#delete(path) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/kward/session_trash.rb', line 14 def delete(path) return false unless File.exist?(path) return true if move_to_trash(path) File.delete(path) if File.exist?(path) true end |