Is there a more efficient way to extract the file extensions in ruby? I currently do the following.

RUBY:
  1. ext = File.basename(filepath).reverse.split('.')[0].reverse

One Comment

  1. shajith says:

    Try File.extname(filepath).

    Tip: Use something.methods to peek at what is available. And set up the ri documentation base so you can query for docs (as in: ri File.extname)

Leave a Reply