Recall & Review
beginner
What does the Ruby
Dir.pwd method return?It returns the current working directory as a string. Think of it as asking, "Where am I right now in the folder system?"
Click to reveal answer
beginner
How do you list all files and folders inside a directory using Ruby?
Use
Dir.entries(path). It returns an array of all entries (files and folders) inside the given directory path.Click to reveal answer
intermediate
What is the difference between
Dir.entries and Dir.glob?Dir.entries lists everything inside a directory. Dir.glob lets you use patterns (like *.txt) to find specific files.Click to reveal answer
beginner
How do you change the current working directory in Ruby?
Use
Dir.chdir(path). It moves your program's focus to the folder you specify, like changing rooms in a house.Click to reveal answer
beginner
What does
Dir.mkdir('folder_name') do?It creates a new directory (folder) named 'folder_name' in the current location. Like making a new folder in your filing cabinet.
Click to reveal answer
Which Ruby method returns the current working directory?
✗ Incorrect
Dir.pwd returns the current directory path.How do you list all files and folders inside a directory in Ruby?
✗ Incorrect
Dir.entries(path) lists all entries inside the directory.Which method lets you change the current working directory?
✗ Incorrect
Dir.chdir(path) changes the current directory.What does
Dir.mkdir('new_folder') do?✗ Incorrect
It creates a new directory named 'new_folder'.
Which method allows you to find files matching a pattern like '*.rb'?
✗ Incorrect
Dir.glob('*.rb') finds files matching the pattern.Explain how to list all files in a directory and how to filter files by extension using Ruby Dir methods.
Think about how you can see everything first, then pick specific files.
You got /4 concepts.
Describe how to change the current working directory and create a new directory in Ruby.
Imagine moving to a new room and making a new box inside it.
You got /4 concepts.