Complete the code to list all files in the current directory.
files = Dir.[1](".") puts files
The Dir.entries method returns an array of all entries in the specified directory.
Complete the code to change the current working directory to '/tmp'.
Dir.[1]("/tmp")
The Dir.chdir method changes the current working directory to the specified path.
Fix the error in the code to get the current working directory.
current_dir = Dir.[1]The correct method to get the current working directory is Dir.getwd.
Fill both blanks to create a new directory named 'test_dir' and then remove it.
Dir.[1]("test_dir") Dir.[2]("test_dir")
Dir.mkdir creates a new directory, and Dir.rmdir removes an empty directory.
Fill all three blanks to list all Ruby files in the current directory using a pattern.
ruby_files = Dir.[1]("*.[2]") ruby_files.each do |[3]| puts [3] end
Dir.glob lists files matching a pattern. '*.rb' matches Ruby files. The block variable file represents each filename.