method
getbyte
ruby latest stable - Class:
ARGF
getbyte()public
Gets the next 8-bit byte (0..255) from ARGF . Returns nil if called at the end of the stream.
For example:
$ echo "foo" > file $ ruby argf.rb file ARGF .getbyte #=> 102 ARGF .getbyte #=> 111 ARGF .getbyte #=> 111 ARGF .getbyte #=> 10 ARGF .getbyte #=> nil
static VALUE
argf_getbyte(VALUE argf)
{
VALUE ch;
retry:
if (!next_argv()) return Qnil;
if (!RB_TYPE_P(ARGF.current_file, T_FILE)) {
ch = rb_funcall3(ARGF.current_file, rb_intern("getbyte"), 0, 0);
}
else {
ch = rb_io_getbyte(ARGF.current_file);
}
if (NIL_P(ch) && ARGF.next_p != -1) {
argf_close(argf);
ARGF.next_p = 1;
goto retry;
}
return ch;
}