End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
class method
FileUtils.cd
cd(dir, verbose: nil) { |dir| ... }
lib/fileutils.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.0.5/lib/fileutils.rb, line 137
def cd(dir, verbose: nil, &block) # :yield: dir
fu_output_message "cd #{dir}" if verbose
result = Dir.chdir(dir, &block)
fu_output_message 'cd -' if verbose and block
result
end
Changes the current directory to the directory dir.
If this method is called with block, resumes to the previous working directory after the block execution has finished.
Example
FileUtils.cd('/') # change directory FileUtils.cd('/', verbose: true) # change directory and report it FileUtils.cd('/') do # change directory # ... # do something end # return to original directory