Method: FunWith::Files::FilePath.tmpfile
- Defined in:
- lib/fun_with/files/file_path.rb
.tmpfile(ext = :tmp, &block) ⇒ Object
The file is created within a temporary directory
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/fun_with/files/file_path.rb', line 29 def self.tmpfile( ext = :tmp, &block ) filename = rand( 2 ** 64 ).to_s(16).fwf_filepath.ext( ext ) if block_given? self.tmpdir do |tmp| yield tmp.join( filename ).touch end else self.tmpdir.join( filename ).touch end end |