ios.rewind → 0
Positions ios to the beginning of input, resetting lineno to zero.
f = File.new("testfile") f.readline #=> "This is line one\n" f.rewind #=> 0 f.lineno #=> 0 f.readline #=> "This is line one\n"
Source Code
/* * call-seq: * ios.rewind => 0 * * Positions <em>ios</em> to the beginning of input, resetting * <code>lineno</code> to zero. * * f = File.new("testfile") * f.readline #=> "This is line one\n" * f.rewind #=> 0 * f.lineno #=> 0 * f.readline #=> "This is line one\n" */ static VALUE rb_io_rewind(io) VALUE io; { OpenFile *fptr; GetOpenFile(io, fptr); if (io_seek(fptr, 0L, 0) != 0) rb_sys_fail(fptr->path); clearerr(fptr->f); if (io == current_file) { gets_lineno -= fptr->lineno; } fptr->lineno = 0; return INT2FIX(0); }
<code/>and<pre/>for code samples.