I'm writing a small ruby gem which should generate couple of files, so I'm using executables.
How can I (in my ruby code) get the current folder of the command line from which the gem was executed?
For example, when I run my tool in this path:
~/Projects/MyProject/ $ my-tool
How can I get the ~/Projects/MyProject/
in my ruby code?
Thank you
Dir.pwd
or Dir.getwd
should do. Please note they return full absolute path, with ~
expanded.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.