Method: Agoo::ErrorStream#write

Defined in:
ext/agoo/error_stream.c

#write(str) ⇒ Object

call-seq: write(str)

Write the str to the stream, accumulating it until flush is called.



67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'ext/agoo/error_stream.c', line 67

static VALUE
es_write(VALUE self, VALUE str) {
    ErrorStream	es = (ErrorStream)DATA_PTR(self);
    int		cnt = (int)RSTRING_LEN(str);

    if (NULL == es) {
	rb_raise(rb_eIOError, "error stream has been closed.");
    }
    if (NULL == (es->text = agoo_text_append(es->text, StringValuePtr(str), cnt))) {
	rb_raise(rb_eNoMemError, "Failed to allocate memory for the error stream puts.");
    }
    return INT2NUM(cnt);
}