Skip to content

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

instance method

Dir#seek

dir.seek( integer ) → dir

Seeks to a particular location in dir. integer must be a value returned by Dir#tell.

Example
d = Dir.new("testdir")   #=> #<Dir:0x401b3c40>
d.read                   #=> "."
i = d.tell               #=> 12
d.read                   #=> ".."
d.seek(i)                #=> #<Dir:0x401b3c40>
d.read                   #=> ".."
See also #rewind #tell #read #to_path also in 4.1 · 4.0 · 3.4 · 3.3 · 3.1 · 3.0