I have a nested path e.g. backend/docs/file.yml which I want to split into a filename (file.yml) and dir (backend/docs) variables. I wanted to do a similar assignment to the one below, but without the sep variable, which is not needed anywhere.
dir, sep, filename = params[:path].rpartition("/")
File.basename and File.dirname are not good enough, as they always treat the last string as a filename (dir in backend/docs/dir/ is treated a file, not directory).