long

Ruby code posted
created at 07 May 19:18, updated at 07 May 19:18

Edit | Back
1
2
3
4
5
6
7
8
9
10
11
  require 'tempfile'
  
  file = Tempfile.new('foo')
  file.path      # => A unique filename in the OS's temp directory,
                 #    e.g.: "/tmp/foo.24722.0"
                 #    This filename contains 'foo' in its basename. This filename contains 'foo' in its basename. This filename contains 'foo' in its basename. This filename contains 'foo' in its basename. This filename contains 'foo' in its basename. This filename contains 'foo' in its basename. This filename contains 'foo' in its basename. This filename contains 'foo' in its basename. This filename contains 'foo' in its basename.
  file.write("hello world")
  file.rewind
  file.read      # => "hello world"
  file.close
  file.unlink    # deletes the temp file
734 Bytes in 2 ms with coderay