Bug #15411 ยป tempfile-docs.patch
lib/tempfile.rb | ||
---|---|---|
#
|
||
# file = Tempfile.new('foo')
|
||
# begin
|
||
# ...do something with file...
|
||
# # ...do something with file...
|
||
# ensure
|
||
# file.close
|
||
# file.unlink # deletes the temp file
|
||
... | ... | |
# same Tempfile object from multiple threads then you should protect it with a
|
||
# mutex.
|
||
class Tempfile < DelegateClass(File)
|
||
# call-seq:
|
||
# new(basename = "", [tmpdir = Dir.tmpdir], [options])
|
||
#
|
||
# Creates a temporary file with permissions 0600 (= only readable and
|
||
# writable by the owner) and opens it with mode "w+".
|
||
#
|
||
... | ... | |
# +File.open+. This is mostly useful for specifying encoding
|
||
# options, e.g.:
|
||
#
|
||
# Tempfile.new('hello', '/home/aisaka', :encoding => 'ascii-8bit')
|
||
# Tempfile.new('hello', '/home/aisaka', encoding: 'ascii-8bit')
|
||
#
|
||
# # You can also omit the 'tmpdir' parameter:
|
||
# Tempfile.new('hello', :encoding => 'ascii-8bit')
|
||
# Tempfile.new('hello', encoding: 'ascii-8bit')
|
||
#
|
||
# Note: +mode+ keyword argument, as accepted by Tempfile, can only be
|
||
# numeric, combination of the modes defined in File::Constants.
|
||
#
|
||
# === Exceptions
|
||
#
|
||
... | ... | |
#
|
||
# file = Tempfile.new('foo')
|
||
# begin
|
||
# ...do something with file...
|
||
# # ...do something with file...
|
||
# ensure
|
||
# file.close
|
||
# file.unlink # deletes the temp file
|
||
... | ... | |
# file = Tempfile.new('foo')
|
||
# file.unlink # On Windows this silently fails.
|
||
# begin
|
||
# ... do something with file ...
|
||
# # ... do something with file ...
|
||
# ensure
|
||
# file.close! # Closes the file handle. If the file wasn't unlinked
|
||
# # because #unlink failed, then this method will attempt
|
||
... | ... | |
# In any case, all arguments (<code>*args</code>) will be passed to Tempfile.new.
|
||
#
|
||
# Tempfile.open('foo', '/home/temp') do |f|
|
||
# ... do something with f ...
|
||
# # ... do something with f ...
|
||
# end
|
||
#
|
||
# # Equivalent:
|
||
# f = Tempfile.open('foo', '/home/temp')
|
||
# begin
|
||
# ... do something with f ...
|
||
# # ... do something with f ...
|
||
# ensure
|
||
# f.close
|
||
# end
|
||
... | ... | |
# <code>**options</code>) will be treated as Tempfile.new.
|
||
#
|
||
# Tempfile.create('foo', '/home/temp') do |f|
|
||
# ... do something with f ...
|
||
# # ... do something with f ...
|
||
# end
|
||
#
|
||
def Tempfile.create(basename="", tmpdir=nil, mode: 0, **options)
|