Module: IO::generic_readable
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Defined in: | ext/stringio/stringio.c |
Instance Method Summary
-
#read_nonblock(integer[, outbuf [, opts]]) ⇒ String
Similar to
#read
, but raisesEOFError
at end of string unless the exception: false option is passed in. -
#readbyte ⇒ Fixnum
See
IO#readbyte
. -
#readchar ⇒ String
See
IO#readchar
. -
#readline(sep = $/) ⇒ String
See
IO#readline
. -
#readpartial(integer[, outbuf]) ⇒ String
Alias for #sysread.
-
#sysread(integer[, outbuf]) ⇒ String
(also: #readpartial)
Similar to
#read
, but raisesEOFError
at end of string instead of returningnil
, as well asIO#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.
# File 'ext/stringio/stringio.c', line 1471
static VALUE strio_read_nonblock(int argc, VALUE *argv, VALUE self) { VALUE opts = Qnil, val; rb_scan_args(argc, argv, "11:", NULL, NULL, &opts); if (!NIL_P(opts)) { argc--; } val = strio_read(argc, argv, self); if (NIL_P(val)) { if (!NIL_P(opts) && rb_hash_lookup2(opts, sym_exception, Qundef) == Qfalse) return Qnil; else rb_eof_error(); } return val; }
#readbyte ⇒ Fixnum
See IO#readbyte
.
# File 'ext/stringio/stringio.c', line 881
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
.
# File 'ext/stringio/stringio.c', line 867
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
?
String
#readline(limit) ⇒ String
?
#readline(sep, limit) ⇒ String
?
See IO#readline
.
# File 'ext/stringio/stringio.c', line 1174
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
String
#readpartial(integer[, outbuf]) ⇒ String
Alias for #sysread.
#sysread(integer[, outbuf]) ⇒ String
#readpartial(integer[, outbuf]) ⇒ String
Also known as: #readpartial
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.
# File 'ext/stringio/stringio.c', line 1454
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; }