Ruby/File Directory/tmpdir

Материал из Wiki.crossplatform.ru

Перейти к: навигация, поиск

Dir.tmpdir provides the path to the temporary directory on the current system

require "tmpdir"
puts Dir.tmpdir



use Dir.tmpdir with File.join to create a platform-independent way of creating a temporary file:

require "tmpdir"
tempfilename = File.join(Dir.tmpdir, "myapp.dat")
tempfile = File.new(tempfilename, "w")
tempfile.puts "This is only temporary"
tempfile.close
File.delete(tempfilename)