method
dirname
![Moderate documentation Importance_2](https://d2vfyqvduarcvs.cloudfront.net/images/importance_2.png?1349367920)
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
![Default_avatar_30](https://www.gravatar.com/avatar/b850a6cd0c0f8993fa152645ca9a7fbd?size=30&default=http://apidock.com/images/default_avatar_30.png)
5 thanks
For the filename use File.basename
File.basename provides what File.dirname omits.