Method: Pathname#delete!

Defined in:
lib/pleasant_path/pathname.rb

#delete!self

Recursively deletes the directory or file indicated by the Pathname. Similar to Pathname#rmtree, but does not raise an exception if the file does not exist. Returns the Pathname.

Examples:

File.exist?("path/to/file")   # == true

Pathname.new("path").delete!  # == Pathname.new("path")

Dir.exist?("path")            # == false
Dir.exist?("path/to")         # == false
File.exist?("path/to/file")   # == false

Returns:

  • (self)


354
355
356
357
# File 'lib/pleasant_path/pathname.rb', line 354

def delete!
  self.rmtree if self.exist?
  self
end