method
nread
v2_1_10 -
Show latest stable
- Class:
IO
nread()public
Returns number of bytes that can be read without blocking. Returns zero if no information available.
static VALUE
io_nread(VALUE io)
{
rb_io_t *fptr;
int len;
ioctl_arg n;
GetOpenFile(io, fptr);
rb_io_check_readable(fptr);
len = rb_io_read_pending(fptr);
if (len > 0) return INT2FIX(len);
if (!FIONREAD_POSSIBLE_P(fptr->fd)) return INT2FIX(0);
if (ioctl(fptr->fd, FIONREAD, &n)) return INT2FIX(0);
if (n > 0) return ioctl_arg2num(n);
return INT2FIX(0);
} 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