ÿØÿà JFIF    ÿÛ „  ( %!1!%)+//.383,7(-.+  -%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ     ÿÄ J    ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ   ÿÄ *  !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú "SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5 ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍѶ¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e ríV ?> ......................................... ............................................................................. ÿØÿà JFIF    ÿÛ „  ( %!1!%)+//.383,7(-.+  -%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ     ÿÄ J    ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ   ÿÄ *  !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú "SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5 ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍѶ¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e ríV ?> ......................................... ............................................................................. ???????????????????????????????????? ???????????????????????????????????? ÿØÿà JFIF    ÿÛ „  ( %!1!%)+//.383,7(-.+  -%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ     ÿÄ J    ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ   ÿÄ *  !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú "SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5 ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍѶ¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e ríV ?> ......................................... ............................................................................. ÿØÿà JFIF    ÿÛ „  ( %!1!%)+//.383,7(-.+  -%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ     ÿÄ J    ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ   ÿÄ *  !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú "SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5 ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍѶ¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e ríV ?> ......................................... ............................................................................. ???????????????????????????????????? ???????????????????????????????????? U:RDoc::NormalClass[iI" Tempfile:ET@I"DelegateClass(File);To:RDoc::Markup::Document: @parts[o;;[5o:RDoc::Markup::Paragraph;[I"2A utility class for managing temporary files.;To:RDoc::Markup::BlankLineo; ;[I"@There are two kind of methods of creating a temporary file:;T@o:RDoc::Markup::List: @type: BULLET: @items[o:RDoc::Markup::ListItem: @label0;[o; ;[I""Tempfile.create (recommended);To;;0;[o; ;[I"XTempfile.new and Tempfile.open (mostly for backward compatibility, not recommended);T@o; ;[ I"3Tempfile.create creates a usual \File object. ;TI"1The timing of file deletion is predictable. ;TI"7Also, it supports open-and-unlink technique which ;TI";removes the temporary file immediately after creation.;T@o; ;[I"@Tempfile.new and Tempfile.open creates a \Tempfile object. ;TI"8The created file is removed by the GC (finalizer). ;TI"4The timing of file deletion is not predictable.;T@S:RDoc::Markup::Heading: leveli: textI" Synopsis;T@o:RDoc::Markup::Verbatim;[3I"require 'tempfile' ;TI" ;TI"$# Tempfile.create with a block ;TI"/# The filename are choosen automatically. ;TI"X# (You can specify the prefix and suffix of the filename by an optional argument.) ;TI"Tempfile.create {|f| ;TI" f.puts "foo" ;TI" f.rewind ;TI"* f.read # => "foo\n" ;TI"B} # The file is removed at block exit. ;TI" ;TI"'# Tempfile.create without a block ;TI"6# You need to unlink the file in non-block form. ;TI"f = Tempfile.create ;TI"f.puts "foo" ;TI" f.close ;TI" "/tmp/" (no filename since no file) ;TI"f.puts "foo" ;TI"f.rewind ;TI"*f.read # => "foo\n" ;TI" f.close ;TI" ;TI"5# Tempfile.create(anonymous: true) with a block ;TI"+Tempfile.create(anonymous: true) {|f| ;TI"8 # The file is already removed because anonymous. ;TI"G f.path # => "/tmp/" (no filename since no file) ;TI" f.puts "foo" ;TI" f.rewind ;TI"* f.read # => "foo\n" ;TI"} ;TI" ;TI"5# Not recommended: Tempfile.new without a block ;TI" file = Tempfile.new('foo') ;TI"Gfile.path # => A unique filename in the OS's temp directory, ;TI"2 # e.g.: "/tmp/foo.24722.0" ;TI"G # This filename contains 'foo' in its basename. ;TI"file.write("hello world") ;TI"file.rewind ;TI"'file.read # => "hello world" ;TI"file.close ;TI",file.unlink # deletes the temp file ;T: @format0S;;i;I")About Tempfile.new and Tempfile.open;T@o; ;[I"also avoids the overhead and complications of delegation.;T@o;;[I"&Tempfile.create('foo') do |file| ;TI"' # ...do something with file... ;TI" end ;T;0S;;i;I"Unlink after creation;T@o; ;[ I"OOn POSIX systems, it's possible to unlink a file right after creating it, ;TI"Nand before closing it. This removes the filesystem entry without closing ;TI"Mthe file handle, so it ensures that only the processes that already had ;TI"Hthe file handle open can access the file's contents. It's strongly ;TI"Lrecommended that you do this if you do not want any other processes to ;TI"Kbe able to read from or write to the Tempfile, and you do not need to ;TI")know the Tempfile's filename either.;T@o; ;[I"XAlso, this guarantees the temporary file is removed even if Ruby exits abnormally. ;TI"SThe OS reclaims the storage for the temporary file when the file is closed or ;TI"5the Ruby process exits (normally or abnormally).;T@o; ;[ I"PFor example, a practical use case for unlink-after-creation would be this: ;TI"Nyou need a large byte buffer that's too large to comfortably fit in RAM, ;TI"Oe.g. when you're writing a web server and you want to buffer the client's ;TI"file upload data.;T@o; ;[I"@`Tempfile.create(anonymous: true)` supports this behavior. ;TI"It also works on Windows.;T@S;;i;I"Minor notes;T@o; ;[I"TTempfile's filename picking method is both thread-safe and inter-process-safe: ;TI"Rit guarantees that no other threads or processes will pick the same filename.;T@o; ;[I"PTempfile itself however may not be entirely thread-safe. If you access the ;TI"Rsame Tempfile object from multiple threads then you should protect it with a ;TI" mutex.;T: @fileI"lib/tempfile.rb;T:0@omit_headings_from_table_of_contents_below0;0;0[[U:RDoc::Constant[iI" VERSION;TI"Tempfile::VERSION;T: public0o;;[o; ;[I"The version;T;@;0@@cRDoc::NormalClass0[[[I" class;T[[;[[I" create;TI"lib/tempfile.rb;T[I"new;T@[I" open;T@[:protected[[: private[[I"create_anonymous;T@[I"create_with_filename;T@[I" instance;T[[;[ [I" close;T@[I" close!;T@[I" delete;T@[I" length;T@[I" open;T@[I" path;T@[I" size;T@[I" unlink;T@[;[[;[[[U:RDoc::Context::Section[i0o;;[;0;0[@@cRDoc::TopLevel