From: Michael Fellinger Date: 2009-06-01T09:41:02+09:00 Subject: [ruby-core:23652] Re: Counterpart to File.extname On Mon, 1 Jun 2009 03:35:47 +0900 Ian Duggan wrote: > On Sun, May 31, 2009 at 1:52 AM, Martin DeMello > wrote: > > File.extname ought to have a complementary method that gets > > everything but the extension. Useful for scripts that need to > > mangle a filename > > Is this too much? I admit I find all the File.* ugly to type every > time I have to do it. It seems verbose. > > irb --> fn = "/a/b/c/d.e" > ==> "/a/b/c/d.e" > > irb --> File.join(File.dirname(fn), File.basename(fn, > File.extname(fn))) ==> "/a/b/c/d" require 'pathname' fn = Pathname('/a/b/c/d.e') # # fn.dirname + fn.basename('.*') # # -- ^ manveru