Module: IO::generic_readable
- Included in:
- StringIO
- Defined in:
- stringio.c
Instance Method Summary collapse
-
#read_nonblock(integer[, outbuf [, opts]]) ⇒ String
Similar to #read, but raises
EOFError
at end of string unless the exception: false option is passed in. -
#readbyte ⇒ Fixnum
See IO#readbyte.
-
#readchar ⇒ String
See IO#readchar.
-
#readline ⇒ Object
See IO#readline.
-
#readpartial ⇒ Object
Similar to #read, but raises
EOFError
at end of string instead of returningnil
, as well as IO#sysread does. -
#sysread ⇒ Object
Similar to #read, but raises
EOFError
at end of string instead of returningnil
, as well as IO#sysread does.
Instance Method Details
#read_nonblock(integer[, outbuf [, opts]]) ⇒ String
Similar to #read, but raises EOFError
at end of string unless the exception: false option is passed in.
1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 |
# File 'stringio.c', line 1361
static VALUE
strio_read_nonblock(int argc, VALUE *argv, VALUE self)
{
VALUE opts = Qnil, val;
int no_exception = 0;
rb_scan_args(argc, argv, "11:", NULL, NULL, &opts);
if (!NIL_P(opts)) {
argc--;
if (Qfalse == rb_hash_aref(opts, sym_exception))
no_exception = 1;
}
val = strio_read(argc, argv, self);
if (NIL_P(val)) {
if (no_exception)
return Qnil;
else
rb_eof_error();
}
return val;
}
|
#readbyte ⇒ Fixnum
See IO#readbyte.
842 843 844 845 846 847 848 |
# File 'stringio.c', line 842
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;
}
|
#readchar ⇒ String
See IO#readchar.
828 829 830 831 832 833 834 |
# File 'stringio.c', line 828
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.
1077 1078 1079 1080 1081 1082 1083 |
# File 'stringio.c', line 1077
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 #readpartial(integer[, outbuf]) ⇒ String
Similar to #read, but raises EOFError
at end of string instead of returning nil
, as well as IO#sysread does.
1344 1345 1346 1347 1348 1349 1350 1351 1352 |
# File 'stringio.c', line 1344
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 #readpartial(integer[, outbuf]) ⇒ String
Similar to #read, but raises EOFError
at end of string instead of returning nil
, as well as IO#sysread does.
1344 1345 1346 1347 1348 1349 1350 1351 1352 |
# File 'stringio.c', line 1344
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;
}
|