End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Pathname#open
pathname.open()
pathname.open(mode="r" [, opt]) → file
pathname.open([mode [, perm]] [, opt]) → file
pathname.open(mode="r" [, opt]) {|file| block } → obj
pathname.open([mode [, perm]] [, opt]) {|file| block } → obj
ext/pathname/pathname.c
View on GitHub ↗
static VALUE
path_open(int argc, VALUE *argv, VALUE self)
{
VALUE args[4];
int n;
args[0] = get_strpath(self);
n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]);
if (rb_block_given_p()) {
return rb_block_call_kw(rb_cFile, id_open, 1+n, args, 0, 0, RB_PASS_CALLED_KEYWORDS);
}
else {
return rb_funcallv_kw(rb_cFile, id_open, 1+n, args, RB_PASS_CALLED_KEYWORDS);
}
}
Opens the file for reading or writing.
See File.open.