On Thu, 28 Jan 2016 10:45:04 -0800, tbrowder wrote:
> Class IO:Path currently has many methods for handling path name.  The
> list currently includes:
> 
> method abspath
> method basename
> method extension
> method dirname
> method volume
> method parts
> method path
> method Str
> 
> I would like to see a new method named, say, stemname, which would be
> similar to basename except any suffix is removed.
> 
> # existing method: basename
> > say IO::Path.new("docs/README.pod").basename;
> README.pod
> 
> # existing method: extension
> > say IO::Path.new("docs/README.pod").extension;
> pod
> 
> # new method: stemname
> > say IO::Path.new("docs/README.pod").stemname;
> README
> 
> # updated old method: parts
> > say IO::Path.new("docs/README.pod").parts.perl;
> {:basename("README.pod"), :directory("doc"), :dirname("doc"),
> :volume(""), :basename("README.pod"); :stemname("README")}
> 
> Best regards,
> 
> -Tom

Thanks for the suggestion, however, I'm going to reject this RFC.

You showed the most common example—a single part extension—but it has the same 
limitations as the old .extension method (e.g., I'd expect the "stemname" of 
"foo.tar.gz" to be "foo" not "foo.tar").

As of Rakudo 2017.04.2, you can use .extension method remove the extension, 
removing however many parts you want to remove, and you can then call .basename 
on the returned path to get the "stemname":

    "docs/README.pod".IO.extension("").basename.say
    # OUTPUT: README

    "docs/foo.tar.gz".IO.extension("", :2parts).basename.say'
    # OUTPUT: foo

Reply via email to