Method: Pathname#copy

Defined in:
lib/pleasant_path/pathname.rb

#copy(destination) ⇒ Pathname

Copies the file or directory indicated by the Pathname to destination, in the same manner as FileUtils.cp_r. Returns destination as a Pathname.

Examples:

FileUtils.mkpath("dir/files")
FileUtils.touch("dir/files/file1")
FileUtils.mkpath("other_dir")

Pathname.new("dir/files").copy("other_dir/same_files")
  # == Pathname.new("other_dir/same_files")

File.exist?("dir/files/file1")             # == true
File.exist?("other_dir/same_files/file1")  # == true

Parameters:

Returns:

See Also:



625
626
627
628
# File 'lib/pleasant_path/pathname.rb', line 625

def copy(destination)
  FileUtils.cp_r(self, destination)
  destination.to_pathname
end