Class: File
- Inherits:
-
Object
- Object
- File
- Defined in:
- lib/helpers/trash.rb
Class Method Summary collapse
-
.trash(filename) ⇒ Object
Moves the file whose filename is given to the Trash, Recycle Bin or equivalent of the OS being used.
Class Method Details
.trash(filename) ⇒ Object
Moves the file whose filename is given to the Trash, Recycle Bin or equivalent of the OS being used.
Will return a NotImplementtedError if your OS is not implemented.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/helpers/trash.rb', line 8 def self.trash(filename) filename = self.(filename) # Different Operating systems # case Sys::Uname.sysname # when "Darwin" if filename =~ /^\/Volumes\/(.+?)\// # External Volume, send to /Volumes/-volume name-/.Trashes/501/ FileUtils.mv(filename,"/Volumes/#{$1}/.Trashes/501/") else # Main drive, move to ~/.Trash/ FileUtils.mv(filename,self.("~/.Trash")) end # when /^Microsoft Windows/ # raise NotImplementedError, "" # end end |