Created
February 26, 2014 06:22
-
-
Save MtnBiker/9224528 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Exercise3. Make use of the class Dir for the following - | |
# | |
# Display your current working directory. | |
# Create a new directory tmp under your working directory. | |
# Change your working directory to tmp | |
# Display your current working directory. | |
# Go back to your original directory. | |
# Delete the tmp directory. | |
puts "1. #{ENV['PWD']}" | |
Dir.mkdir('tmp') unless Dir.exists?('tmp') | |
Dir.chdir("/tmp") | |
puts "2. #{ENV['PWD']}" # => not in tmp | |
Dir.chdir('..') | |
puts "3. #{ENV['PWD']}" | |
Dir.delete('tmp') # => Errno::EACCES: Permission denied - tmp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment