method
basename
![Moderate documentation Importance_2](https://d2vfyqvduarcvs.cloudfront.net/images/importance_2.png?1349367920)
basename(*args)
public
Returns the last component of the filename given in file_name, which can be formed using both File::SEPARATOR and File::ALT_SEPARATOR as the separator when File::ALT_SEPARATOR is not nil. If suffix is given and present at the end of file_name, it is removed. If suffix is “.*”, any extension will be removed.
File.basename("/home/gumby/work/ruby.rb") #=> "ruby.rb" File.basename("/home/gumby/work/ruby.rb", ".rb") #=> "ruby" File.basename("/home/gumby/work/ruby.rb", ".*") #=> "ruby"
Register or
log in
to add new notes.
metavida -
January 27, 2010
![Default_avatar_30](https://www.gravatar.com/avatar/b526ab2828ebed7151e14174a8d242d4?default=http://apidock.com/images/default_avatar_30.png&size=30)
3 thanks
For the file path use File.dirname
File.dirname provides what File.basename omits.