Class: Pathname
Class Method Summary collapse
-
.tempfile ⇒ Object
Creates a new temp file using Tempfile.new and returns the Pathname object for that file.
Instance Method Summary collapse
-
#cp(new_path, options = {}) ⇒ Object
(also: #copy)
Copies self to
new_path
using FileUtils.cp. -
#install(dest, options = {}) ⇒ Object
Copies/install self to
dest
using FileUtils.install. -
#mv(new_path, options = {}) ⇒ Object
(also: #move)
Moves self to
new_path
using FileUtils.mv.
Class Method Details
Instance Method Details
#cp(new_path, options = {}) ⇒ Object Also known as: copy
Copies self to new_path
using FileUtils.cp.
See documentation for FileUtils.cp for a list of valid options
.
Returns Pathname object for new_file
file.
38 39 40 41 |
# File 'lib/quality_extensions/pathname.rb', line 38 def cp(new_path, = {}) FileUtils.cp self.to_s, new_path.to_s, Pathname.new(new_path) end |
#install(dest, options = {}) ⇒ Object
Copies/install self to dest
using FileUtils.install.
If src is not same as dest, copies it and changes the permission mode to mode. If dest is a directory, destination is dest/src.
FileUtils.install 'ruby', '/usr/local/bin/ruby', :mode => 0755, :verbose => true
FileUtils.install 'lib.rb', '/usr/local/lib/ruby/site_ruby', :verbose => true
Returns Pathname object for dest
file.
54 55 56 57 |
# File 'lib/quality_extensions/pathname.rb', line 54 def install(dest, = {}) FileUtils.install self.to_s, dest.to_s, Pathname.new(dest) end |
#mv(new_path, options = {}) ⇒ Object Also known as: move
Moves self to new_path
using FileUtils.mv.
See documentation for FileUtils.mv for a list of valid options
.
Returns Pathname object for new_file
file.
26 27 28 29 |
# File 'lib/quality_extensions/pathname.rb', line 26 def mv(new_path, = {}) FileUtils.mv self.to_s, new_path.to_s, Pathname.new(new_path) end |