rewind()
public
Positions ios to the beginning of input, resetting lineno to zero.
f = File.new("testfile")
f.readline
f.rewind
f.lineno
f.readline
Note that it cannot be used with streams such as pipes, ttys, and sockets.
Show source
static VALUE
rb_io_rewind(VALUE io)
{
rb_io_t *fptr;
GetOpenFile(io, fptr);
if (io_seek(fptr, 0L, 0) < 0 && errno) rb_sys_fail_path(fptr->pathv);
if (io == ARGF.current_file) {
ARGF.lineno -= fptr->lineno;
}
fptr->lineno = 0;
if (fptr->readconv) {
clear_readconv(fptr);
}
return INT2FIX(0);
}