Module
Instance Methods
ext/io/console/console.c
View on GitHub
static VALUE
io_getch(int argc, VALUE *argv, VALUE io)
{
return rb_funcallv(io, id_getc, argc, argv);
}
See IO#getch
.
ext/io/console/console.c
View on GitHub
static VALUE
io_getpass(int argc, VALUE *argv, VALUE io)
{
VALUE str;
rb_check_arity(argc, 0, 1);
prompt(argc, argv, io);
rb_check_funcall(io, id_flush, 0, 0);
str = rb_ensure(gets_call, io, puts_call, io);
return str_chomp(str);
}
See IO#getpass
.
ext/stringio/stringio.c
View on GitHub
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;
}
Similar to read, but raises EOFError
at end of string unless the +exception: false+ option is passed in.
ext/stringio/stringio.c
View on GitHub
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;
}
Like getbyte
, but raises an exception if already at end-of-stream; see Byte IO.
ext/stringio/stringio.c
View on GitHub
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;
}
Like getc
, but raises an exception if already at end-of-stream; see Character IO.
ext/stringio/stringio.c
View on GitHub
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;
}
ext/stringio/stringio.c
View on GitHub
An alias for sysread
ext/stringio/stringio.c
View on GitHub
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;
}
Similar to read, but raises EOFError
at end of string instead of returning nil
, as well as IO#sysread
does.