Module: IO::readable

Included in:
StringIO
Defined in:
stringio.c

Instance Method Summary collapse

Instance Method Details

#sysread(integer[, outbuf]) ⇒ String

Similar to #read, but raises EOFError at end of string instead of returning nil, as well as IO#sysread does.

Returns:

  • (String)

1338
1339
1340
1341
1342
1343
1344
1345
1346
# File 'stringio.c', line 1338

static VALUE
strio_sysread(int argc, VALUE *argv, VALUE self)
{
    VALUE val = rb_funcall2(self, rb_intern("read"), argc, argv);
    if (NIL_P(val)) {
	rb_eof_error();
    }
    return val;
}

#readbyteFixnum

See IO#readbyte.

Returns:

  • (Fixnum)

844
845
846
847
848
849
850
# File 'stringio.c', line 844

static VALUE
strio_readbyte(VALUE self)
{
    VALUE c = rb_funcall2(self, rb_intern("getbyte"), 0, 0);
    if (NIL_P(c)) rb_eof_error();
    return c;
}

#readcharString

See IO#readchar.

Returns:

  • (String)

830
831
832
833
834
835
836
# File 'stringio.c', line 830

static VALUE
strio_readchar(VALUE self)
{
    VALUE c = rb_funcall2(self, rb_intern("getc"), 0, 0);
    if (NIL_P(c)) rb_eof_error();
    return c;
}

#readline(sep = $/) ⇒ String #readline(limit) ⇒ String? #readline(sep, limit) ⇒ String?

See IO#readline.

Overloads:

  • #readline(sep = $/) ⇒ String

    Returns:

    • (String)
  • #readline(limit) ⇒ String?

    Returns:

    • (String, nil)
  • #readline(sep, limit) ⇒ String?

    Returns:

    • (String, nil)

1079
1080
1081
1082
1083
1084
1085
# File 'stringio.c', line 1079

static VALUE
strio_readline(int argc, VALUE *argv, VALUE self)
{
    VALUE line = rb_funcall2(self, rb_intern("gets"), argc, argv);
    if (NIL_P(line)) rb_eof_error();
    return line;
}

#sysread(integer[, outbuf]) ⇒ String

Similar to #read, but raises EOFError at end of string instead of returning nil, as well as IO#sysread does.

Returns:

  • (String)

1338
1339
1340
1341
1342
1343
1344
1345
1346
# File 'stringio.c', line 1338

static VALUE
strio_sysread(int argc, VALUE *argv, VALUE self)
{
    VALUE val = rb_funcall2(self, rb_intern("read"), argc, argv);
    if (NIL_P(val)) {
	rb_eof_error();
    }
    return val;
}

#sysread(integer[, outbuf]) ⇒ String

Similar to #read, but raises EOFError at end of string instead of returning nil, as well as IO#sysread does.

Returns:

  • (String)

1338
1339
1340
1341
1342
1343
1344
1345
1346
# File 'stringio.c', line 1338

static VALUE
strio_sysread(int argc, VALUE *argv, VALUE self)
{
    VALUE val = rb_funcall2(self, rb_intern("read"), argc, argv);
    if (NIL_P(val)) {
	rb_eof_error();
    }
    return val;
}