Chdir Method with Block
Posted by root Fri, 22 Aug 2008 15:13:00 GMT
# 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