method
getbyte
v2_1_10 -
Show latest stable
- Class:
IO
getbyte()public
Gets the next 8-bit byte (0..255) from ios. Returns nil if called at end of file.
f = File.new("testfile") f.getbyte #=> 84 f.getbyte #=> 104
VALUE
rb_io_getbyte(VALUE io)
{
rb_io_t *fptr;
int c;
GetOpenFile(io, fptr);
rb_io_check_byte_readable(fptr);
READ_CHECK(fptr);
if (fptr->fd == 0 && (fptr->mode & FMODE_TTY) && RB_TYPE_P(rb_stdout, T_FILE)) {
rb_io_t *ofp;
GetOpenFile(rb_stdout, ofp);
if (ofp->mode & FMODE_TTY) {
rb_io_flush(rb_stdout);
}
}
if (io_fillbuf(fptr) < 0) {
return Qnil;
}
fptr->rbuf.off++;
fptr->rbuf.len--;
c = (unsigned char)fptr->rbuf.ptr[fptr->rbuf.off-1];
return INT2FIX(c & 0xff);
} Related methods
- Instance methods
- <<
- advise
- autoclose=
- autoclose?
- binmode
- binmode?
- bytes
- chars
- close
- close_on_exec=
- close_on_exec?
- close_read
- close_write
- closed?
- codepoints
- cooked
- cooked!
- each
- each_byte
- each_char
- each_codepoint
- each_line
- echo=
- echo?
- eof
- eof?
- expect
- external_encoding
- fcntl
- fdatasync
- fileno
- flush
- fsync
- getbyte
- getc
- getch
- gets
- iflush
- initialize_copy
- inspect
- internal_encoding
- ioctl
- ioflush
- isatty
- lineno
- lineno=
- lines
- noecho
- nonblock
- nonblock=
- nonblock?
- nread
- oflush
- pid
- pos
- pos=
- printf
- putc
- puts
- raw
- raw!
- read
- read_nonblock
- readbyte
- readchar
- readline
- readlines
- readpartial
- ready?
- reopen
- rewind
- scanf
- seek
- set_encoding
- stat
- sync
- sync=
- sysread
- sysseek
- syswrite
- tell
- to_i
- to_io
- tty?
- ungetbyte
- ungetc
- wait
- wait_readable
- wait_writable
- winsize
- winsize=
- write
- write_nonblock
- Class methods
- binread
- binwrite
- console
- copy_stream
- for_fd
- foreach
- new
- open
- pipe
- popen
- read
- readlines
- select
- sysopen
- try_convert
- write
- Private methods
-
block_scanf -
soak_up_spaces