method
dirname
v1_9_3_392 -
Show latest stable
- Class:
File
dirname(p1)public
Returns all components of the filename given in file_name except the last one. The filename must be formed using forward slashes (“/”) regardless of the separator used on the local file system.
File.dirname("/home/gumby/work/ruby.rb") #=> "/home/gumby/work"
1Note
For the filename use File.basename
File.basename provides what File.dirname omits.