Skip to content

End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

ARGF#rewind

ARGF.rewind → 0

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

Example
ARGF.readline   #=> "This is line one\n"
ARGF.rewind     #=> 0
ARGF.lineno     #=> 0
ARGF.readline   #=> "This is line one\n"
See also #readpartial #seek #read_nonblock #set_encoding also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0