open(...)
public
Equivalent to StringIO.new except that when it is called with a block, it
yields with the new instance and
closes it, and returns the result which returned from the block.
Show source
/*
* call-seq: StringIO.open(string=""[, mode]) {|strio| ...}
*
* Equivalent to StringIO.new except that when it is called with a block, it
* yields with the new instance and closes it, and returns the result which
* returned from the block.
*/
static VALUE
strio_s_open(argc, argv, klass)
int argc;
VALUE *argv;
VALUE klass;
{
VALUE obj = rb_class_new_instance(argc, argv, klass);
if (!rb_block_given_p()) return obj;
return rb_ensure(rb_yield, obj, strio_finalize, obj);
}