Method: File.open
- Defined in:
- io.c
.open(*args) ⇒ Object
call-seq:
IO.open(fd, mode="r" [, opt]) -> io
IO.open(fd, mode="r" [, opt]) { |io| block } -> obj
With no associated block, IO.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.
See IO.new for a description of the fd, mode and opt parameters.
6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 |
# File 'io.c', line 6378
static VALUE
rb_io_s_open(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;
}
|