public Method

IO.fileno

ios.fileno     fixnum
ios.to_i       fixnum

Returns an integer representing the numeric file descriptor for ios.

$stdin.fileno    #=> 0
$stdout.fileno   #=> 1

Source Code

/*
*  call-seq:
*     ios.fileno    => fixnum
*     ios.to_i      => fixnum
*  
*  Returns an integer representing the numeric file descriptor for
*  <em>ios</em>.
*     
*     $stdin.fileno    #=> 0
*     $stdout.fileno   #=> 1
*/

static VALUE
rb_io_fileno(io)
   VALUE io;
{
   OpenFile *fptr;
   int fd;

   GetOpenFile(io, fptr);
   fd = fileno(fptr->f);
   return INT2FIX(fd);
}
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.