Sha256: ecc6562d37427b1f9806fe8f2e4189d3baeb6e852778b5eeb06f4c748878dfbb

Contents?: true

Size: 1.32 KB

Versions: 1

Compression:

Stored size: 1.32 KB

Contents

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
  <title>read (Rev::Buffer)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
  <pre>/**
 *  call-seq:
 *    Rev::Buffer#read(length = nil) -&gt; String
 * 
 * Read the specified abount of data from the buffer.  If no value
 * is given the entire contents of the buffer are returned.  Any data
 * read from the buffer is cleared.
 */
static VALUE Rev_Buffer_read(int argc, VALUE *argv, VALUE self)
{
  VALUE length_obj, str;
  int length;
  struct buffer *buf;

  Data_Get_Struct(self, struct buffer, buf);

  if(rb_scan_args(argc, argv, &quot;01&quot;, &amp;length_obj) == 1) {
    length = NUM2INT(length_obj);
  } else {
    if(buf-&gt;size == 0)
      return rb_str_new2(&quot;&quot;);

    length = buf-&gt;size;
  }

  if(length &gt; buf-&gt;size)
    length = buf-&gt;size;

  if(length &lt; 1)
    rb_raise(rb_eArgError, &quot;length must be greater than zero&quot;);

  str = rb_str_new(0, length);
  buffer_read(buf, RSTRING_PTR(str), length);

  return str;
}</pre>
</body>
</html>

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rev-0.1.2 doc/rdoc/classes/Rev/Buffer.src/M000026.html