Deleting a file is quite simple in Ruby.
We can use the delete() method to delete a file.
File.delete("myfirstfile.txt")
And, the file myfirstfile.txt is deleted from the current directory.
We can use the rename() method to delete a file.
Let's say, we have a file called myfirstfile.txt and we want to rename it to newfirstfile.txt.
File.rename("myfirstfile.txt","newfirstfile.txt")
Now, if you see open your folder, you can find the file, myfirstfile.txt got renamed to newfirstfile.txt.