File: C:/Ruby27-x64/share/doc/ruby/html/IO/generic_readable.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>module IO::generic_readable - RDoc Documentation</title>
<script type="text/javascript">
var rdoc_rel_prefix = "../";
var index_rel_prefix = "../";
</script>
<script src="../js/navigation.js" defer></script>
<script src="../js/search.js" defer></script>
<script src="../js/search_index.js" defer></script>
<script src="../js/searcher.js" defer></script>
<script src="../js/darkfish.js" defer></script>
<link href="../css/fonts.css" rel="stylesheet">
<link href="../css/rdoc.css" rel="stylesheet">
<body id="top" role="document" class="module">
<nav role="navigation">
<div id="project-navigation">
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
<h2>
<a href="../index.html" rel="home">Home</a>
</h2>
<div id="table-of-contents-navigation">
<a href="../table_of_contents.html#pages">Pages</a>
<a href="../table_of_contents.html#classes">Classes</a>
<a href="../table_of_contents.html#methods">Methods</a>
</div>
</div>
<div id="search-section" role="search" class="project-section initially-hidden">
<form action="#" method="get" accept-charset="utf-8">
<div id="search-field-wrapper">
<input id="search-field" role="combobox" aria-label="Search"
aria-autocomplete="list" aria-controls="search-results"
type="text" name="search" placeholder="Search" spellcheck="false"
title="Type to search, Up and Down to navigate, Enter to load">
</div>
<ul id="search-results" aria-label="Search Results"
aria-busy="false" aria-expanded="false"
aria-atomic="false" class="initially-hidden"></ul>
</form>
</div>
</div>
<div id="class-metadata">
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
<h3>Methods</h3>
<ul class="link-list" role="directory">
<li ><a href="#method-i-getch">#getch</a>
<li ><a href="#method-i-getpass">#getpass</a>
<li ><a href="#method-i-read_nonblock">#read_nonblock</a>
<li ><a href="#method-i-readbyte">#readbyte</a>
<li ><a href="#method-i-readchar">#readchar</a>
<li ><a href="#method-i-readline">#readline</a>
<li ><a href="#method-i-readpartial">#readpartial</a>
<li ><a href="#method-i-sysread">#sysread</a>
</ul>
</div>
</div>
</nav>
<main role="main" aria-labelledby="module-IO::generic_readable">
<h1 id="module-IO::generic_readable" class="module">
module IO::generic_readable
</h1>
<section class="description">
</section>
<section id="5Buntitled-5D" class="documentation-section">
<section id="public-instance-5Buntitled-5D-method-details" class="method-section">
<header>
<h3>Public Instance Methods</h3>
</header>
<div id="method-i-getch" class="method-detail ">
<div class="method-heading">
<span class="method-callseq">
getch(min: nil, time: nil, intr: nil) → char
</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>See <a href="../IO.html#method-i-getch"><code>IO#getch</code></a>.</p>
<div class="method-source-code" id="getch-source">
<pre>static VALUE
io_getch(int argc, VALUE *argv, VALUE io)
{
return rb_funcallv(io, id_getc, argc, argv);
}</pre>
</div>
</div>
</div>
<div id="method-i-getpass" class="method-detail ">
<div class="method-heading">
<span class="method-callseq">
getpass(prompt=nil) → string
</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>See <a href="../IO.html#method-i-getpass"><code>IO#getpass</code></a>.</p>
<div class="method-source-code" id="getpass-source">
<pre>static VALUE
io_getpass(int argc, VALUE *argv, VALUE io)
{
VALUE str;
rb_check_arity(argc, 0, 1);
prompt(argc, argv, io);
str = str_chomp(rb_funcallv(io, id_gets, 0, 0));
puts_call(io);
return str;
}</pre>
</div>
</div>
</div>
<div id="method-i-read_nonblock" class="method-detail ">
<div class="method-heading">
<span class="method-callseq">
read_nonblock(integer[, outbuf [, opts]]) → string
</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>Similar to read, but raises <code>EOFError</code> at end of string unless the +exception: false+ option is passed in.</p>
<div class="method-source-code" id="read_nonblock-source">
<pre>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;
}</pre>
</div>
</div>
</div>
<div id="method-i-readbyte" class="method-detail ">
<div class="method-heading">
<span class="method-callseq">
readbyte → fixnum
</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>See <a href="../IO.html#method-i-readbyte"><code>IO#readbyte</code></a>.</p>
<div class="method-source-code" id="readbyte-source">
<pre>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;
}</pre>
</div>
</div>
</div>
<div id="method-i-readchar" class="method-detail ">
<div class="method-heading">
<span class="method-callseq">
readchar → string
</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>See <a href="../IO.html#method-i-readchar"><code>IO#readchar</code></a>.</p>
<div class="method-source-code" id="readchar-source">
<pre>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;
}</pre>
</div>
</div>
</div>
<div id="method-i-readline" class="method-detail ">
<div class="method-heading">
<span class="method-callseq">
readline(sep=$/, chomp: false) → string
</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-heading">
<span class="method-callseq">
readline(limit, chomp: false) → string or nil
</span>
</div>
<div class="method-heading">
<span class="method-callseq">
readline(sep, limit, chomp: false) → string or nil
</span>
</div>
<div class="method-description">
<p>See <a href="../IO.html#method-i-readline"><code>IO#readline</code></a>.</p>
<div class="method-source-code" id="readline-source">
<pre>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;
}</pre>
</div>
</div>
</div>
<div id="method-i-readpartial" class="method-detail ">
<div class="method-heading">
<span class="method-callseq">
readpartial(integer[, outbuf]) → string
</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>Similar to read, but raises <code>EOFError</code> at end of string instead of returning <code>nil</code>, as well as <a href="../IO.html#method-i-sysread"><code>IO#sysread</code></a> does.</p>
<div class="method-source-code" id="readpartial-source">
<pre>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;
}</pre>
</div>
</div>
</div>
<div id="method-i-sysread" class="method-detail ">
<div class="method-heading">
<span class="method-callseq">
sysread(integer[, outbuf]) → string
</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>Similar to read, but raises <code>EOFError</code> at end of string instead of returning <code>nil</code>, as well as <a href="../IO.html#method-i-sysread"><code>IO#sysread</code></a> does.</p>
<div class="method-source-code" id="sysread-source">
<pre>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;
}</pre>
</div>
</div>
</div>
</section>
</section>
</main>
<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.1.1.
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
</footer>