ruby - Finding a path without the file name -


i'm attempting create a program give full path file. can done file.absolute_path, adds file name path. example,

def test   path = file.absolute_path("test.rb")   puts path end #=> c:/users/james/myscripts/test/test.rb 

i need exclude last part /test.rb path contain: c:/users/james/myscripts/test. there way this?

if file.absolute_path("test.txt") gives absolute path, , want directory of it, means want current directory. given by:

dir.pwd 

Comments