Ruby/File Directory/Tempfile
Материал из Wiki.crossplatform.ru
(Различия между версиями)
Версия 17:10, 26 мая 2010
Содержание |
Create a temp file under
require "tempfile" out = Tempfile.new("myhome_tempfile", "/home/leonardr/temp/")
move a file with fileutils
require "fileutils" require "tempfile" out = Tempfile.new("myhome_tempfile", "/home/leonardr/temp/") FileUtils.mv(out.path, "/home/leonardr/old_tempfile")
Tempfile can create temporary files for you
require "tempfile" f = Tempfile.new("myapp") f.puts "Hello" puts f.path f.close
Writing to a Temporary File
require "tempfile" out = Tempfile.new("tempfile") out.path out << "Some text." out.rewind out.read out.close