Skip to content

Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

Tempfile#close

close(unlink_now=false)

Closes the file. If unlink_now is true, then the file will be unlinked (deleted) after closing. Of course, you can choose to later call unlink if you do not unlink it now.

If you don’t explicitly unlink the temporary file, the removal will be delayed until the object is finalized.

See also #close! .open .new #delete also in 4.1 · 4.0 · 3.4 · 3.2 · 3.1 · 3.0