-
-
Notifications
You must be signed in to change notification settings - Fork 3
Home
Daniel Berger edited this page Nov 30, 2021
·
5 revisions
The file-temp library is an alternate way to handle tempfile generation.
gem install file-temp
ffi 1.0.0 or later
require 'file/temp'
fh = File::Temp.new
fh.puts "hello"
fh.close # => Tempfile automatically deleted
fh = File::Temp.new(delete: false)
fh.puts "world"
fh.close # => Tempfile still on your filesystemOther possible constructor options are:
-
directory:- Explicitly specify which directory you want to use instead of TMPDIR. -
options:- options hash passed directly to theFile.openconstructor. -
template:- A template for the tempfile name. The default is "rb_file_temp_XXXXXX".