To find the path of a directory in Ruby, you can use the File.expand_path
method, passing the directory name as an argument:
main.rb44 chars2 lines
This will return the absolute path of the "my_directory" directory. If you need to specify a base directory other than the current working directory, you can provide a second argument to expand_path
:
main.rb88 chars3 lines
This will return the absolute path of "my_directory" within the "/home/user/Documents" directory.
gistlibby LogSnag