method
dirname
dirname(p1)
public
Returns all components of the filename given in file_name except the last one (after first stripping trailing separators). 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"
Register or
log in
to add new notes.
tadman -
April 23, 2009
5 thanks
For the filename use File.basename
File.basename provides what File.dirname omits.