End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
IO#pos
ios.pos → integer
io.c
View on GitHub ↗
static VALUE
rb_io_tell(VALUE io)
{
rb_io_t *fptr;
off_t pos;
GetOpenFile(io, fptr);
pos = io_tell(fptr);
if (pos < 0 && errno) rb_sys_fail_path(fptr->pathv);
pos -= fptr->rbuf.len;
return OFFT2NUM(pos);
}
Alias of #tell
Returns the current offset (in bytes) of ios.
Example
f = File.new("testfile") f.pos #=> 0 f.gets #=> "This is line one\n" f.pos #=> 17