APIdock / Ruby
/
method

rewind

ruby latest stable - Class: ARGF
rewind()
public

Positions the current file to the beginning of input, resetting ARGF.lineno to zero.

ARGF .readline  #=> "This is line one\n"
ARGF .rewind  #=> 0
ARGF .lineno  #=> 0
ARGF .readline  #=> "This is line one\n"
static VALUE
argf_rewind(VALUE argf)
{
 VALUE ret;
 int old_lineno;
 if (!next_argv()) {
 rb_raise(rb_eArgError, "no stream to rewind");
 }
 ARGF_FORWARD(0, 0);
 old_lineno = RFILE(ARGF.current_file)->fptr->lineno;
 ret = rb_io_rewind(ARGF.current_file);
 if (!global_argf_p(argf)) {
 ARGF.last_lineno = ARGF.lineno -= old_lineno;
 }
 return ret;
}

AltStyle によって変換されたページ (->オリジナル) /