<?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 xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: RIO::Doc::SYNOPSIS</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td class="class-mod"><strong>Module</strong></td>
          <td class="class-name-in-header">RIO::Doc::SYNOPSIS</td>
            <td rowspan="2" class="class-header-space-col"></td>
            <td rowspan="2">
                <a class="in-url" href="../../../files/lib/rio/doc/SYNOPSIS_rb.html">
                lib/rio/doc/SYNOPSIS.rb
                </a>
        &nbsp;&nbsp;
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <h1><a href="../Rio.html">Rio</a> - Ruby I/O Comfort Class</h1>
<p>
<a href="../Rio.html">Rio</a> is a convenience class wrapping much of the
functionality of IO, File, Dir, Pathname, FileUtils, Tempfile, StringIO,
OpenURI, Zlib, and CSV.
</p>
<h2><a href="SYNOPSIS.html">SYNOPSIS</a></h2>
<p>
For the following assume:
</p>
<pre>
 astring = &quot;&quot;
 anarray = []
</pre>
<p>
Copy a file into a string
</p>
<pre>
 rio('afile') &gt; astring
</pre>
<p>
Copy the chomped lines of a file into an array
</p>
<pre>
 rio('afile').chomp &gt; anarray
</pre>
<p>
Copy a file into another file
</p>
<pre>
 rio('afile') &gt; rio('another_file')
</pre>
<p>
Copy a file into a directory
</p>
<pre>
 rio('afile') &gt; rio('adir')
</pre>
<p>
Copy an entire directory structure into another directory
</p>
<pre>
 rio('adir') &gt; rio('another_directory')
</pre>
<p>
Copy a web page into a file
</p>
<pre>
 rio('http://rubydoc.org/') &gt; rio('afile')
</pre>
<p>
Copy a file from a ftp server into a file
</p>
<pre>
 rio('ftp://host/afile.gz') &gt; rio('afile.gz')
</pre>
<p>
Copy a gzipped file un-gzipping it
</p>
<pre>
 rio('afile.gz').gzip &gt; rio('afile')
</pre>
<p>
Copy a file from a ftp server into a local file un-gzipping it
</p>
<pre>
 rio('ftp://host/afile.gz').gzip &gt; rio('afile')
</pre>
<p>
Copy a plain file, gzipping it
</p>
<pre>
 rio('afile.gz').gzip &lt; rio('afile')
</pre>
<p>
Iterate over the entries in a directory
</p>
<pre>
 rio('adir').entries { |entrio| ... }
</pre>
<p>
Iterate over only the files in a directory
</p>
<pre>
 rio('adir').files { |entrio| ... }
</pre>
<p>
Iterate over only the .rb files in a directory
</p>
<pre>
 rio('adir').files('*.rb') { |entrio| ... }
</pre>
<p>
Create an array of the .rb entries in a directory
</p>
<pre>
 anarray = rio('adir')['*.rb']
</pre>
<p>
Iterate over the .rb files in a directory and its subdirectories
</p>
<pre>
 rio('adir').all.files('*.rb') { |entrio| ... }
</pre>
<p>
Create an array of the .rb entries in a directory and its subdirectories
</p>
<pre>
 anarray = rio('adir').all['*.rb']
</pre>
<p>
Create an array of the .rb files in a directory and its subdirectories
</p>
<pre>
 anarray = rio('adir').all.files['*.rb']
</pre>
<p>
Copy an entire directory structure but only the .rb files from a directory
and its subdirectories into another directory
</p>
<pre>
 rio('adir').dirs.files('*.rb') &gt; rio('another_directory')
</pre>
<p>
Iterate over the chomped lines of a file
</p>
<pre>
 rio('afile').chomp.lines { |line| ... }
</pre>
<p>
Put the chomped lines of a file into an array
</p>
<pre>
 anarray = rio('afile').chomp.lines[]
</pre>
<p>
Iterate over the first 10 chomped lines of a file
</p>
<pre>
 rio('afile').chomp.lines(0..9) { |line| ... }
</pre>
<p>
Put the first 10 chomped lines of a file into an array
</p>
<pre>
 anarray = rio('afile').chomp.lines[0..9]
</pre>
<p>
Copy the first 10 lines of a file into another file
</p>
<pre>
 rio('afile').lines(0..9) &gt; rio('another_file')
</pre>
<p>
Copy the first 10 lines of a file to stdout
</p>
<pre>
 rio('afile').lines(0..9) &gt; rio(?-)
</pre>
<p>
Copy the first 10 lines of a gzipped file to stdout
</p>
<pre>
 rio('afile.gz').gzip.lines(0..9) &gt; rio(?-)
</pre>
<p>
Copy the first 10 lines of a gzipped file on an ftp server to stdout
</p>
<pre>
 rio('ftp://host/afile.gz').gzip.lines(0..9) &gt; rio(?-)
</pre>
<p>
Put the first 100 chomped lines of a gzipped file into an array
</p>
<pre>
 anarray =  rio('afile.gz').gzip[0...100]
</pre>
<p>
Copy the output of th ps command into an array, skipping the header line
and the ps command entry
</p>
<pre>
 rio(?-,'ps -a').nolines(0,/ps$/) &gt; anarray
</pre>
<p>
Prompt for input and return what was typed
</p>
<pre>
 ans = rio(?-).print(&quot;Type Something: &quot;).chomp.gets
</pre>
<p>
Change the extension of all files with the extension &#8217;.htm&#8217; in
a directory and its subdirectories to have the extension
&#8217;.html&#8217;
</p>
<pre>
 rio('adir').rename.all.files('*.htm') do |htmfile|
   htmfile.extname = '.html'
 end
</pre>
<p>
Create a symbolic link &#8216;asymlink&#8217; in &#8216;adir&#8217; which
refers to &#8216;adir/afile&#8216;
</p>
<pre>
 rio('adir/afile').symlinke('adir/asymlink')
</pre>
<h3>SUGGESTED READING</h3>
<ul>
<li><a href="INTRO.html">RIO::Doc::INTRO</a>

</li>
<li><a href="HOWTO.html">RIO::Doc::HOWTO</a>

</li>
<li><a href="../Rio.html">RIO::Rio</a>

</li>
</ul>

    </div>


   </div>


  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->


  </div>


<div id="validator-badges">
   <p><small>Copyright &copy; 2005 Christopher Kleckner.  <a href="http://www.gnu.org/licenses/gpl.html">All rights reserved</a>.</small></p>
</div>

</body>
</html>