method

dirname

v1_8_6_287 - 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

tadman ยท Apr 23, 20095 thanks

File.basename provides what File.dirname omits.