Skip to content

Instantly share code, notes, and snippets.

@MtnBiker
Created February 26, 2014 06:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MtnBiker/9224528 to your computer and use it in GitHub Desktop.
Save MtnBiker/9224528 to your computer and use it in GitHub Desktop.
# 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