In Files

  • stringio/stringio.c

Class/Module Index [+]

Quicksearch

IO::generic_readable

Public Instance Methods

read_nonblock(integer[, outbuf [, opts]]) → string click to toggle source

Similar to read, but raises EOFError at end of string unless the +exception: false+ option is passed in.

 
               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 click to toggle source

See IO#readbyte.

 
               static VALUE
strio_readbyte(VALUE self)
{
    VALUE c = rb_funcallv(self, rb_intern("getbyte"), 0, 0);
    if (NIL_P(c)) rb_eof_error();
    return c;
}
            
readchar → string click to toggle source

See IO#readchar.

 
               static VALUE
strio_readchar(VALUE self)
{
    VALUE c = rb_funcallv(self, rb_intern("getc"), 0, 0);
    if (NIL_P(c)) rb_eof_error();
    return c;
}
            
readline(sep=$/, chomp: false) → string click to toggle source
readline(limit, chomp: false) → string or nil
readline(sep, limit, chomp: false) → string or nil

See IO#readline.

 
               static VALUE
strio_readline(int argc, VALUE *argv, VALUE self)
{
    VALUE line = rb_funcallv_kw(self, rb_intern("gets"), argc, argv, RB_PASS_CALLED_KEYWORDS);
    if (NIL_P(line)) rb_eof_error();
    return line;
}
            
readpartial(integer[, outbuf]) → string click to toggle source

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

 
               static VALUE
strio_sysread(int argc, VALUE *argv, VALUE self)
{
    VALUE val = rb_funcallv_kw(self, rb_intern("read"), argc, argv, RB_PASS_CALLED_KEYWORDS);
    if (NIL_P(val)) {
        rb_eof_error();
    }
    return val;
}
            
sysread(integer[, outbuf]) → string click to toggle source

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

 
               static VALUE
strio_sysread(int argc, VALUE *argv, VALUE self)
{
    VALUE val = rb_funcallv_kw(self, rb_intern("read"), argc, argv, RB_PASS_CALLED_KEYWORDS);
    if (NIL_P(val)) {
        rb_eof_error();
    }
    return val;
}
            
There is an updated format of the API docs for this version here.