我已经通过看这些文档和谷歌,似乎无法找到的目的.rewind,以及它如何从不同.close,在工作的环境Tempfile.
另外,为什么.read在倒带之前返回一个空字符串?
这是一个例子:
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.
file.write("hello world")
file.rewind
file.read # => "hello world"
file.close
file.unlink # deletes the temp file
Run Code Online (Sandbox Code Playgroud)