Chdir Method with Block
Aug 22
2008
2008
Comments Off
# temporary changes the cwd to '/tmp', # adds content to a file and finally restores cwd p Dir.getwd Dir.chdir("/tmp") do p Dir.getwd File.open("test.txt", "a") do |f| f << Time.now << "\n" end end p Dir.getwd