What does the .rewind method do on a Tempfile in ruby? : <p>I've looked through <a href="https://ruby-doc.org/stdlib-1.9.3/libdoc/tempfile/rdoc/Tempfile.html" rel="noreferrer">these docs</a> and Google, and can't seem to find the purpose of <code>.rewind</code>, and how it differs from <code>.close</code>, in the context of working with a <code>Tempfile</code>.</p>

<p>Also, why does <code>.read</code> return an empty string before rewinding?</p>

<p>Here is an example:</p>

<pre><code>file = Tempfile.new('foo')
file.path      # =&gt; 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      # =&gt; "hello world"
file.close
file.unlink    # deletes the temp file
</code></pre>
