lib/refinements/pathnames.rb in refinements-8.5.0 vs lib/refinements/pathnames.rb in refinements-8.5.1
- old
+ new
@@ -26,11 +26,15 @@
def root = new(File::SEPARATOR)
end
refine Pathname do
- def change_dir &block
- block ? Dir.chdir(self, &block) : (Dir.chdir self and self)
+ def change_dir
+ if block_given?
+ Dir.chdir(self) { |path| yield Pathname(path) }
+ else
+ Dir.chdir self and self
+ end
end
def copy to
destination = to.directory? ? to.join(basename) : to
read.then { |content| destination.write content }