0

Example given:

My path is (given by Dir.pwd) "D:/home/usr/documents/text files/2016"

What is a simple way to get the path without the last subfolder.

Result should be: "D:/home/usr/documents/text files"

Currently I do this path = Dir.pwd.reverse.partition("/")[-1].reverse

Works, but I guess I miss the better way.

Thanks in advance!

1 Answers1

0
File.expand_path("..", Dir.pwd)
Pholochtairze
  • 1,836
  • 1
  • 14
  • 18