instance method
IO#pos=
(::Integer new_position) -> ::Integer
pos = new_position → new_position
io.c
View on GitHub ↗
static VALUE
rb_io_set_pos(VALUE io, VALUE offset)
{
rb_io_t *fptr;
rb_off_t pos;
pos = NUM2OFFT(offset);
GetOpenFile(io, fptr);
pos = io_seek(fptr, pos, SEEK_SET);
if (pos < 0 && errno) rb_sys_fail_path(fptr->pathv);
return OFFT2NUM(pos);
}
Seeks to the given new_position (in bytes); see Position:
Example
f = File.open('t.txt') f.tell # => 0 f.pos = 20 # => 20 f.tell # => 20 f.close