End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
class method
Readline.output=
Readline.output = output
ext/readline/readline.c
View on GitHub ↗
static VALUE
readline_s_set_output(VALUE self, VALUE output)
{
rb_io_t *ofp;
int fd;
FILE *f;
if (NIL_P(output)) {
clear_rl_outstream();
}
else {
Check_Type(output, T_FILE);
GetOpenFile(output, ofp);
clear_rl_outstream();
fd = rb_cloexec_dup(ofp->fd);
if (fd == -1)
rb_sys_fail("dup");
f = fdopen(fd, "w");
if (f == NULL) {
int save_errno = errno;
close(fd);
rb_syserr_fail(save_errno, "fdopen");
}
rl_outstream = readline_rl_outstream = f;
readline_outstream = output;
}
return output;
}
Specifies a File object output that is output stream for Readline.readline method.