flush()
Flushes any buffered data within ios to the underlying operating system (note that this is Ruby internal buffering only; the OS may buffer the data as well).
$stdout.print "no newline" $stdout.flush
produces:
no newline
VALUE rb_io_flush(VALUE io) { rb_io_t *fptr; if (TYPE(io) != T_FILE) { return rb_funcall(io, id_flush, 0); } io = GetWriteIO(io); GetOpenFile(io, fptr); if (fptr->mode & FMODE_WRITABLE) { if (io_fflush(fptr) < 0) rb_sys_fail(0); #ifdef _WIN32 fsync(fptr->fd); #endif } if (fptr->mode & FMODE_READABLE) { io_unread(fptr); } return io; }