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.
7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 |
# File 'io.c', line 7163
static VALUE
rb_io_s_open(int argc, VALUE *argv, VALUE klass)
{
VALUE io = rb_class_new_instance_kw(argc, argv, klass, RB_PASS_CALLED_KEYWORDS);
if (rb_block_given_p()) {
return rb_ensure(rb_yield, io, io_close, io);
}
return io;
}
|