method
extname
![Moderate documentation Importance_2](https://d2vfyqvduarcvs.cloudfront.net/images/importance_2.png?1349367920)
extname(p1)
public
Register or
log in
to add new notes.
metavida -
January 27, 2010
![Default_avatar_30](https://www.gravatar.com/avatar/b526ab2828ebed7151e14174a8d242d4?size=30&default=http://apidock.com/images/default_avatar_30.png)
1 thank
File name without the extension
To get the file name without the extension you can use File.extname in combination with File.basename
File.basename("test.rb", File.extname("test.rb")) #=> "test" File.basename("a/b/d/test.rb", File.extname("a/b/d/test.rb")) #=> "test" File.basename("test", File.extname("test")) #=> "test" File.basename(".profile", File.extname(".profile")) #=> ".profile"