From: "Eregon (Benoit Daloze)" Date: 2012-06-30T05:52:39+09:00 Subject: [ruby-core:45970] [ruby-trunk - Feature #6671] File.split_all and File.split_root Issue #6671 has been updated by Eregon (Benoit Daloze). marcandre (Marc-Andre Lafortune) wrote: > How about: > > 'a/b/c'.split('/') # => ['a','b','c'] > > And > > root, _, path = 'a/b/c'.partition('/') > root #=> 'a' > path #=> 'b/c' I guess that might be problematic for absolute paths: > "/a/b/c".split '/' => ["", "a", "b", "c"] > "/a/b/c".partition '/' => ["", "/", "a/b/c"] Is the feature wanted Pathname#each_filename (for split_all) ? ---------------------------------------- Feature #6671: File.split_all and File.split_root https://bugs.ruby-lang.org/issues/6671#change-27575 Author: trans (Thomas Sawyer) Status: Open Priority: Normal Assignee: Category: core Target version: 2.0.0 =begin Is there a method for this already? File.split_all('a/b/c') #=> ['a','b','c'] If not I propose it be added. I've had need of such more than a few times. It's too bad that File.split can't do this, as it would make more sense. And the current method be called `split_base`. In addition `split_root` would be helpful. root, path = File.split_all('a/b/c') root #=> 'a' path #=> 'b/c' =end -- http://bugs.ruby-lang.org/