void ex_rubydo(exarg_T *eap)
{
    int state;
    linenr_T i;

    if (ensure_ruby_initialized())
    {
        if (u_save(eap->line1 - 1, eap->line2 + 1) != OK)
            return;
        for (i = eap->line1; i <= eap->line2; i++) {
            VALUE line, oldline;

            line = oldline = rb_str_new2(ml_get(i));
            rb_lastline_set(line);
            rb_eval_string_protect((char *) eap->arg, &state);
            if (state) {
                error_print(state);
                break;
            }
            line = rb_lastline_get();
            if (!NIL_P(line)) {
                if (TYPE(line) != T_STRING) {
                    EMSG("E265: $_ must be an instance of String");
                    return;
                }
                ml_replace(i, (char_u *) STR2CSTR(line), 1);
                changed();
#ifdef SYNTAX_HL
                syn_changed(i); /* recompute syntax hl. for this line */
#endif
            }
        }
        check_cursor();
        update_curbuf(NOT_VALID);
    }
}

