static public Method

IO.open(...)

IO.open(fd, mode_string="r" )                io
IO.open(fd, mode_string="r" ) {|io| block }  obj

With no associated block, open is a synonym for IO::new. If the optional code block is given, it will be passed io as an argument, and the IO object will automatically be closed when the block terminates. In this instance, IO::open returns the value of the block.

Source Code

/*
*  call-seq:
*     IO.open(fd, mode_string="r" )               => io
*     IO.open(fd, mode_string="r" ) {|io| block } => obj
*  
*  With no associated block, <code>open</code> is a synonym for
*  <code>IO::new</code>. If the optional code block is given, it will
*  be passed <i>io</i> as an argument, and the IO object will
*  automatically be closed when the block terminates. In this instance,
*  <code>IO::open</code> returns the value of the block.
*     
*/

static VALUE
rb_io_s_open(argc, argv, klass)
   int argc;
   VALUE *argv;
   VALUE klass;
{
   VALUE io = rb_class_new_instance(argc, argv, klass);

   if (rb_block_given_p()) {
       return rb_ensure(rb_yield, io, io_close, io);
   }

   return io;
}
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.