instance method
StringIO#close_read
() -> nil
close_read → nil
ext/stringio/stringio.c
View on GitHub ↗
static VALUE
strio_close_read(VALUE self)
{
struct StringIO *ptr = StringIO(self);
if (!(ptr->flags & FMODE_READABLE)) {
rb_raise(rb_eIOError, "closing non-duplex IO for reading");
}
RBASIC(self)->flags &= ~STRIO_READABLE;
return Qnil;
}
Closes self for reading; closed-write setting remains unchanged; returns nil:
Example
strio = StringIO.new strio.closed_read? # => false strio.close_read # => nil strio.closed_read? # => true strio.closed_write? # => false strio.read # Raises IOError: not opened for reading
Related: StringIO#close, StringIO#close_write.