Method: StringIO#getbyte

Defined in:
ext/stringio/stringio.c

#getbytenil

Reads and returns the next 8-bit byte from the stream; see Byte IO.

Returns:

  • (nil)


890
891
892
893
894
895
896
897
898
899
900
# File 'ext/stringio/stringio.c', line 890

static VALUE
strio_getbyte(VALUE self)
{
    struct StringIO *ptr = readable(self);
    int c;
    if (ptr->pos >= RSTRING_LEN(ptr->string)) {
  return Qnil;
    }
    c = RSTRING_PTR(ptr->string)[ptr->pos++];
    return CHR2FIX(c);
}