method

dirname

v2_1_10 - Show latest stable - Class: File
dirname(p1)
public

Returns all components of the filename given in file_name except the last one. The filename can be formed using both File::SEPARATOR and File::ALT_SEPARATOR as the separator when File::ALT_SEPARATOR is not nil.

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.