public Method

IO.pos

ios.pos      integer
ios.tell     integer

Returns the current offset (in bytes) of ios.

f = File.new("testfile")
f.pos    #=> 0
f.gets   #=> "This is line one\n"
f.pos    #=> 17

Source Code

/*
*  call-seq:
*     ios.pos     => integer
*     ios.tell    => integer
*  
*  Returns the current offset (in bytes) of <em>ios</em>.
*     
*     f = File.new("testfile")
*     f.pos    #=> 0
*     f.gets   #=> "This is line one\n"
*     f.pos    #=> 17
*/

static VALUE
rb_io_tell(io)
    VALUE io;
{
   OpenFile *fptr;
   off_t pos;

   GetOpenFile(io, fptr);
   pos = io_tell(fptr);
   if (pos < 0) rb_sys_fail(fptr->path);
   return OFFT2NUM(pos);
}
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.