Is there an easy and fast operation to just strip the last path of a directory of a path in ruby without using regex?
path examples:
has="/my/to/somewhere/id"
wants="/my/to/somewhere"
Currently I am using:
path.split('/')[0...-1].join('/')
For has
I will always know the id
so I could also use:
path.sub("/#{id}", '')
So my question is really, which operation is faster??