SeeWhyAnEyeSee

Get dir.

Dec 8th, 2014
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.60 KB | None | 0 0
  1. puts "Where to explore?"
  2. print "> "; $command = gets.chomp #cd so program knows we are changing directories
  3.                  
  4. $command.gsub!("cd ","") #REMOVE cd and a space because appropriate input would be "cd c:\example"
  5.     if Dir.exists?($command) # METHOD CDTODIR02 #
  6.      Dir.chdir($command); puts "\n"
  7.     elsif File.file?($command)
  8.      $command = File.dirname $command
  9.      Dir.chdir($command); puts "\n"
  10.     elsif not Dir.exists?($command)
  11.      puts "#{$command} not found."
  12.     else # ELSE CDTODIR02 #
  13.      puts "An unknown error occurred, please check your input."
  14.      puts "#{$command} not recognized."
  15.     end # METHOD CDTODIR02 #
Advertisement
Add Comment
Please, Sign In to add comment