Skip to content
Daniel Berger edited this page Nov 30, 2021 · 5 revisions

Description

The file-temp library is an alternate way to handle tempfile generation.

Installation

gem install file-temp

Requirements

ffi 1.0.0 or later

Synopsis

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 filesystem

Other possible constructor options are:

  • directory: - Explicitly specify which directory you want to use instead of TMPDIR.
  • options: - options hash passed directly to the File.open constructor.
  • template: - A template for the tempfile name. The default is "rb_file_temp_XXXXXX".
Clone this wiki locally