The absolute_path()
method of the File
class in Ruby converts the path-name of a file to an absolute path-name.
File.absolute_path(path_name)
path_name
: This is the path-name
of the file. It is the relative path of the file whose starting point or absolute file path we want to get.
The absolute file name of path_name
is returned.
Welcome to Edpresso!
test1.txt
and test2.txt
.path-names
of the files whose absolute file paths we need.absolute_path()
is invoked to get the absolute paths of the files. Then, we print the results to the console.