File.split_all and File.split_root
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_root would be helpful.
root, path = File.split_all('a/b/c')
root #=> 'a'
path #=> 'b/c'
#3 [ruby-core:45970] Updated by Benoit Daloze about 4 years ago
marcandre (Marc-Andre Lafortune) wrote:
How about:'a/b/c'.split('/') # => ['a','b','c']
Androot, _, 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) ?
#6 [ruby-core:48434] Updated by Yusuke Endoh almost 4 years ago
- Assignee changed from Yusuke Endoh to Yukihiro Matsumoto
- Status changed from Open to Assigned
I think I have no right to accept any feature.
Even if I have, I won't use the right without any particular reason.
Yusuke Endoh email@example.com