basename

File.basename(file_name [, suffix] ) รข base_name
Class Public methods

Returns the last component of the filename given in file_name, which can be formed using both File::SEPARATOR and File::ALT_SEPARETOR 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.

File.basename("/home/gumby/work/ruby.rb")          #=> "ruby.rb"
File.basename("/home/gumby/work/ruby.rb", ".rb")   #=> "ruby"
doc_ruby_on_rails
2015-04-06 09:22:18
Comments
Leave a Comment

Please login to continue.