DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Use File.basename To Return Just The Filename

03.31.2010
| 2525 views |
  • submit to reddit
        
File.basename("/home/gumby/work/ruby.rb")          #=> "ruby.rb"
Resources:
 - <a href="http://snippets.dzone.com/posts/show/7317">Return the filename from a file path</a> [dzone.com]