<?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>Class: RIO::Rio</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>Class</strong></td> <td class="class-name-in-header">RIO::Rio</td> <td rowspan="2" class="class-header-space-col"></td> <td rowspan="2"> <a class="in-url" href="../../files/lib/rio_rb.html"> lib/rio.rb </a> <a class="in-url" href="../../files/lib/rio/if/basic_rb.html"> lib/rio/if/basic.rb </a> <a class="in-url" href="../../files/lib/rio/if/dir_rb.html"> lib/rio/if/dir.rb </a> <a class="in-url" href="../../files/lib/rio/if/file_rb.html"> lib/rio/if/file.rb </a> <a class="in-url" href="../../files/lib/rio/if/fileordir_rb.html"> lib/rio/if/fileordir.rb </a> <a class="in-url" href="../../files/lib/rio/if/grande_rb.html"> lib/rio/if/grande.rb </a> <a class="in-url" href="../../files/lib/rio/if/internal_rb.html"> lib/rio/if/internal.rb </a> <a class="in-url" href="../../files/lib/rio/if/methods_rb.html"> lib/rio/if/methods.rb </a> <a class="in-url" href="../../files/lib/rio/if/path_rb.html"> lib/rio/if/path.rb </a> <a class="in-url" href="../../files/lib/rio/if/stream_rb.html"> lib/rio/if/stream.rb </a> <a class="in-url" href="../../files/lib/rio/if/test_rb.html"> lib/rio/if/test.rb </a> </td> </tr> <tr class="top-aligned-row"> <td><strong>Parent:</strong></td> <td> Base </td> </tr> </table> </div> <!-- banner header --> <div id="bodyContent"> <div id="contextContent"> <div id="description"> <p> See also: <a href="Doc/SYNOPSIS.html">RIO::Doc::SYNOPSIS</a>; <a href="Doc/INTRO.html">RIO::Doc::INTRO</a>; <a href="Doc/HOWTO.html">RIO::Doc::HOWTO</a>. </p> </div> </div> <div id="method-list"> <h3 class="section-bar">Methods</h3> <div class="name-list"> <a href="#M000103">+</a> <a href="#M000102">/</a> <a href="#M000051"><</a> <a href="#M000050"><<</a> <a href="#M000012">==</a> <a href="#M000013">===</a> <a href="#M000016">=~</a> <a href="#M000048">></a> <a href="#M000049">>></a> <a href="#M000044">[]</a> <a href="#M000062">a</a> <a href="#M000063">a!</a> <a href="#M000086">abs</a> <a href="#M000180">abs?</a> <a href="#M000181">absolute?</a> <a href="#M000024">all</a> <a href="#M000023">all?</a> <a href="#M000163">atime</a> <a href="#M000088">base</a> <a href="#M000092">basename</a> <a href="#M000097">basename=</a> <a href="#M000120">binmode</a> <a href="#M000148">blockdev?</a> <a href="#M000056">bytes</a> <a href="#M000149">chardev?</a> <a href="#M000017">chdir</a> <a href="#M000075">chomp</a> <a href="#M000074">chomp?</a> <a href="#M000141">close</a> <a href="#M000157">closed?</a> <a href="#M000071">closeoncopy</a> <a href="#M000073">closeoncopy?</a> <a href="#M000068">closeoneof</a> <a href="#M000070">closeoneof?</a> <a href="#M000116">contents</a> <a href="#M000164">ctime</a> <a href="#M000046">delete</a> <a href="#M000047">delete!</a> <a href="#M000151">dir?</a> <a href="#M000150">directory?</a> <a href="#M000093">dirname</a> <a href="#M000098">dirname=</a> <a href="#M000018">dirs</a> <a href="#M000009">dup</a> <a href="#M000045">each</a> <a href="#M000122">each_byte</a> <a href="#M000123">each_line</a> <a href="#M000020">entries</a> <a href="#M000136">eof?</a> <a href="#M000015">eql?</a> <a href="#M000166">executable?</a> <a href="#M000167">executable_real?</a> <a href="#M000152">exist?</a> <a href="#M000085">expand_path</a> <a href="#M000089">ext</a> <a href="#M000091">ext?</a> <a href="#M000094">extname</a> <a href="#M000096">extname=</a> <a href="#M000142">fcntl</a> <a href="#M000153">file?</a> <a href="#M000095">filename</a> <a href="#M000099">filename=</a> <a href="#M000144">fileno</a> <a href="#M000021">files</a> <a href="#M000027">find</a> <a href="#M000121">flush</a> <a href="#M000158">fnmatch?</a> <a href="#M000084">fspath</a> <a href="#M000145">fsync</a> <a href="#M000159">ftype</a> <a href="#M000052">getrec</a> <a href="#M000114">gets</a> <a href="#M000028">glob</a> <a href="#M000174">grpowned?</a> <a href="#M000105">gsub</a> <a href="#M000076">gzip</a> <a href="#M000077">gzip?</a> <a href="#M000014">hash</a> <a href="#M000109">host</a> <a href="#M000005">initialize_copy</a> <a href="#M000010">inspect</a> <a href="#M000143">ioctl</a> <a href="#M000137">ioh</a> <a href="#M000138">ios</a> <a href="#M000100">join</a> <a href="#M000106">join!</a> <a href="#M000011">length</a> <a href="#M000117">lineno</a> <a href="#M000118">lineno=</a> <a href="#M000055">lines</a> <a href="#M000161">lstat</a> <a href="#M000111">merge</a> <a href="#M000032">mkdir</a> <a href="#M000031">mkpath</a> <a href="#M000139">mode</a> <a href="#M000140">mode?</a> <a href="#M000165">mtime</a> <a href="#M000004">new</a> <a href="#M000072">nocloseoncopy</a> <a href="#M000069">nocloseoneof</a> <a href="#M000019">nodirs</a> <a href="#M000090">noext</a> <a href="#M000022">nofiles</a> <a href="#M000059">nolines</a> <a href="#M000058">norecords</a> <a href="#M000026">norecurse</a> <a href="#M000061">norows</a> <a href="#M000079">nosync</a> <a href="#M000110">opaque</a> <a href="#M000007">open</a> <a href="#M000156">open?</a> <a href="#M000173">owned?</a> <a href="#M000081">path</a> <a href="#M000162">pipe?</a> <a href="#M000041">pos</a> <a href="#M000043">pos=</a> <a href="#M000126">print</a> <a href="#M000127">print!</a> <a href="#M000129">printf</a> <a href="#M000128">printf!</a> <a href="#M000131">putc</a> <a href="#M000130">putc!</a> <a href="#M000132">puts</a> <a href="#M000133">puts!</a> <a href="#M000064">r</a> <a href="#M000065">r!</a> <a href="#M000038">read</a> <a href="#M000168">readable?</a> <a href="#M000169">readable_real?</a> <a href="#M000125">readline</a> <a href="#M000124">readlines</a> <a href="#M000036">readlink</a> <a href="#M000119">recno</a> <a href="#M000057">records</a> <a href="#M000025">recurse</a> <a href="#M000087">rel</a> <a href="#M000037">rename</a> <a href="#M000053">reset</a> <a href="#M000039">rewind</a> <a href="#M000006">rio</a> <a href="#M000054">rl</a> <a href="#M000033">rm</a> <a href="#M000029">rmdir</a> <a href="#M000030">rmtree</a> <a href="#M000107">rootpath</a> <a href="#M000112">route_from</a> <a href="#M000113">route_to</a> <a href="#M000060">rows</a> <a href="#M000108">scheme</a> <a href="#M000040">seek</a> <a href="#M000175">setgid?</a> <a href="#M000176">setuid?</a> <a href="#M000177">size</a> <a href="#M000178">size?</a> <a href="#M000115">slurp</a> <a href="#M000154">socket?</a> <a href="#M000101">split</a> <a href="#M000160">stat</a> <a href="#M000172">sticky?</a> <a href="#M000104">sub</a> <a href="#M000035">symlink</a> <a href="#M000155">symlink?</a> <a href="#M000078">sync</a> <a href="#M000080">sync?</a> <a href="#M000042">tell</a> <a href="#M000008">to_s</a> <a href="#M000083">to_uri</a> <a href="#M000082">to_url</a> <a href="#M000034">touch</a> <a href="#M000146">tty?</a> <a href="#M000147">ungetc</a> <a href="#M000066">w</a> <a href="#M000067">w!</a> <a href="#M000170">writable?</a> <a href="#M000171">writable_real?</a> <a href="#M000135">write</a> <a href="#M000134">write!</a> <a href="#M000179">zero?</a> </div> </div> </div> <!-- if includes --> <div id="includes"> <h3 class="section-bar">Included Modules</h3> <div id="includes-list"> <span class="include-name">Local</span> <span class="include-name">Enumerable</span> </div> </div> <div id="section"> <div id="attribute-list"> <h3 class="section-bar">Attributes</h3> <div class="name-list"> <table> <tr class="top-aligned-row context-row"> <td class="context-item-name">state</td> <td class="context-item-value"> [R] </td> <td class="context-item-desc"></td> </tr> </table> </div> </div> <!-- if method_list --> <div id="methods"> <h3 class="section-bar">Public Class methods</h3> <div id="method-M000004" class="method-detail"> <a name="M000004"></a> <div class="method-heading"> <a href="Rio.src/M000004.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000004.html');return false;"> <span class="method-name">new</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> See <a href="../RIO.html#M000001">RIO.rio</a> </p> </div> </div> <div id="method-M000006" class="method-detail"> <a name="M000006"></a> <div class="method-heading"> <a href="Rio.src/M000006.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000006.html');return false;"> <span class="method-name">rio</span><span class="method-args">(*args) {|self| ...}</span> </a> </div> <div class="method-description"> <p> See <a href="../RIO.html#M000001">RIO.rio</a> </p> </div> </div> <h3 class="section-bar">Public Instance methods</h3> <div id="method-M000103" class="method-detail"> <a name="M000103"></a> <div class="method-heading"> <a href="Rio.src/M000103.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000103.html');return false;"> <span class="method-name">+</span><span class="method-args">(arg)</span> </a> </div> <div class="method-description"> <p> Create a <a href="Rio.html">Rio</a> referencing <a href="Rio.html#M000008">Rio#to_s</a> + arg.to_s </p> <pre> rio('afile') + '-0.1' #=> rio('afile-0.1') </pre> </div> </div> <div id="method-M000102" class="method-detail"> <a name="M000102"></a> <div class="method-heading"> <a href="Rio.src/M000102.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000102.html');return false;"> <span class="method-name">/</span><span class="method-args">(arg)</span> </a> </div> <div class="method-description"> <p> Subdirectory operator. </p> <p> Effectively the same as <a href="Rio.html#M000100">Rio#join</a>(arg) </p> <pre> a = rio('a') b = rio('b') c = a/b #=> rio('a/b') ario = rio('adir') ario/'afile.rb' #=> rio('ario/afile.rb') ario/'b'/'c'/'d' #=> rio('ario/b/c/d') ario = rio('adir') ario /= 'afile.rb' #=> rio('ario/afile.rb') </pre> </div> </div> <div id="method-M000051" class="method-detail"> <a name="M000051"></a> <div class="method-heading"> <a href="Rio.src/M000051.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000051.html');return false;"> <span class="method-name"><</span><span class="method-args">(source)</span> </a> </div> <div class="method-description"> <p> Grande Copy-From Operator </p> <p> The copy-from grande-operator copies a <a href="Rio.html">Rio</a> from another <a href="Rio.html">Rio</a> or another ruby object. Its operation is dependent on the the file system objects referenced, the rio options set, and the state of its source and destination. In the broadest of terms it could be described as doing the following: </p> <pre> source.each do |entry| destination << entry end </pre> <p> That is to say, it iterates through its argument, calling the copy-from operator again for each element. While it is not implemented like this, and the above code would not give the same results, This generalized description is convenient. For example the code: </p> <pre> dst < src # is like src.each { |line| dst << line } </pre> <p> for any of the following definitions of src and dst </p> <ul> <li>copying files <pre> src = rio('afile') dst = rio('acopy') </pre> </li> <li>copying parts of files <pre> src = rio('afile').lines(0..9) dst = rio('acopy') </pre> </li> <li>copying directories <pre> src = rio('srcdir') dst = rio('dstdir') </pre> </li> <li>copy directories selectively <pre> src = rio('srcdir').dirs(/^\./).files('*.tmp') dst = rio('dstdir') </pre> </li> <li>copying to a file from an array <pre> src = ["line0\n","line1\n"] dst = rio('afile') </pre> </li> <li>copying to a directory from an array <pre> array = [rio("file1"),rio("file2")] dst = rio('adir') </pre> </li> </ul> <p> Arrays are handled differently depending on whether the rio references a file or a directory. </p> <ul> <li>If the destination is a file. <pre> dest = rio('afile') dest < array # is roughly equivelent to array.each do |el| case el when ::String then dest.print(el) when ::Rio then dest << el else dest << rio(el) end </pre> </li> <li>If the destination is a directory <pre> dest = rio('adir') dest < array # is roughly equivelent to array.each do |el| case el when ::String then rio(el) when ::Rio then dest << el else dest << rio(el) end </pre> </li> </ul> <p> To improve run-time efficiency, <a href="Rio.html">Rio</a> will choose from among several strategies when copying. For instance when no file or directory filtering is specified, FileUtils#cp_r is used to copy directories; and when no line filtering is specified, FileUtils#cp is used to copy files. </p> <pre> rio('adir') < rio('anotherdir') # 'anotherdir' is copied to 'adir' using FileUtils#cp_r rio('adir') < rio('anotherdir').files('*.rb') # copy only .rb files rio('afile') < rio('anotherfile') # 'anotherfile' is copied to 'afile' using FileUtils#cp rio('afile') < ios # ios must be an IO object opened for reading rio('afile') < astring # basically the same as rio('afile').print(astring) anarray = [ astring, rio('anotherfile') ] rio('afile') < anarray # copies each element to 'afile' as if one had written ario = rio('afile') anarray.each do |el| ario << el end ario.close rio('skeldir') < rio('adir').dirs # copy only the directory structure rio('destdir') < rio('adir').dirs.files(/^\./) # copy the directory structure and all dot files </pre> <p> See also <a href="Rio.html">Rio</a>#> (copy-to), <a href="Rio.html#M000045">Rio#each</a>, <a href="Rio.html">Rio</a>#[] </p> </div> </div> <div id="method-M000050" class="method-detail"> <a name="M000050"></a> <div class="method-heading"> <a href="Rio.src/M000050.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000050.html');return false;"> <span class="method-name"><<</span><span class="method-args">(source)</span> </a> </div> <div class="method-description"> <p> Grande Append-From Operator </p> <p> The append-from grande-operator copies a <a href="Rio.html">Rio</a> from another <a href="Rio.html">Rio</a> or another ruby object. This behaves like <a href="Rio.html">Rio</a>#< (copy-from) except unopened Rios are opened for append. </p> <p> The following summarizes how objects are copied: </p> <table> <tr><td valign="top">IO:</td><td>IO#each is used to iterate through the source with each record appended to the <a href="Rio.html">Rio</a> </td></tr> <tr><td valign="top">Array:</td><td>Each element of the Array is appended individually to the <a href="Rio.html">Rio</a>. </td></tr> <tr><td valign="top">String:</td><td>The string is appended to the <a href="Rio.html">Rio</a> using <a href="Rio.html#M000126">Rio#print</a> </td></tr> <tr><td valign="top"><a href="Rio.html">Rio</a>:</td><td>The source <a href="Rio.html">Rio</a> is appended using its <a href="Rio.html">Rio</a>#>> (append-to) operator </td></tr> </table> <p> See <a href="Rio.html">Rio</a>#< (copy-from) </p> </div> </div> <div id="method-M000012" class="method-detail"> <a name="M000012"></a> <div class="method-heading"> <a href="Rio.src/M000012.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000012.html');return false;"> <span class="method-name">==</span><span class="method-args">(other)</span> </a> </div> <div class="method-description"> <p> Equality - calls <a href="Rio.html#M000008">to_s</a> on the other object and compares it with the value returned by <a href="Rio.html#M000008">Rio#to_s</a> </p> </div> </div> <div id="method-M000013" class="method-detail"> <a name="M000013"></a> <div class="method-heading"> <a href="Rio.src/M000013.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000013.html');return false;"> <span class="method-name">===</span><span class="method-args">(other)</span> </a> </div> <div class="method-description"> <p> Equality (for case statements) same as <a href="Rio.html">Rio</a>#== </p> </div> </div> <div id="method-M000016" class="method-detail"> <a name="M000016"></a> <div class="method-heading"> <a href="Rio.src/M000016.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000016.html');return false;"> <span class="method-name">=~</span><span class="method-args">(other)</span> </a> </div> <div class="method-description"> <p> Match - invokes other.=~, passing the value returned by <a href="Rio.html#M000008">Rio#to_s</a> </p> </div> </div> <div id="method-M000048" class="method-detail"> <a name="M000048"></a> <div class="method-heading"> <a href="Rio.src/M000048.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000048.html');return false;"> <span class="method-name">></span><span class="method-args">(destination)</span> </a> </div> <div class="method-description"> <p> Grande Copy-To Operator </p> <p> The copy grande-operator copies a <a href="Rio.html">Rio</a> to a another <a href="Rio.html">Rio</a> or another ruby object. The behaviour and the library used depend on the types of the of the source and destination. For simple file or directory copying ::FileUtils#cp or ::FileUtils#cp_r will be used. If any of the <a href="Rio.html">Rio</a> grande methods are specified for the source or destination, the source <a href="Rio.html">Rio</a> will be iterated through copying records to the destintion as specified. Roughly equivelant to </p> <pre> dst = rio('dst_file') rio('src_file').each do |line| dst.print(line) end dst.close </pre> <p> The destination of the copy operators may be a: </p> <table> <tr><td valign="top">IO:</td><td>Each record of the <a href="Rio.html">Rio</a> is written to the IO using IO#print. The IO must be opened for writing. </td></tr> <tr><td valign="top">Array:</td><td>Each record or entry of the <a href="Rio.html">Rio</a> becomes an element of the array </td></tr> <tr><td valign="top">String:</td><td>Puts the entire contents of the <a href="Rio.html">Rio</a> into the string </td></tr> <tr><td valign="top"><a href="Rio.html">Rio</a>:</td><td>Depends on the destination. See below. </td></tr> </table> <p> Copy a file to a file </p> <pre> rio('src_file') > rio('dst_file') </pre> <p> Copy a file to a directory </p> <pre> rio('src_file') > rio('dst_dir') </pre> <p> Copy a directory to another directory </p> <pre> rio('src_dir') > rio('dst_dir') </pre> <p> Make an ungizipped copy of a gzipped file </p> <pre> rio('src.txt.gz').gzip > rio('dst.txt') </pre> <p> Copying to an array </p> <pre> rio('afile') > ary # each line of the file becomes and element of the ary rio('afile').chomp > ary # same thing with lines chomped rio('afile.gz').gzip.chomp > ary # same thing from a gzipped file rio('afile').lines(0..9) > ary # ary will contain only the first ten lines of the file rio('afile').chomp.lines(0..9) > ary # same thing with lines chomped rio('afile').gzip.chomp.lines(0..9) > ary # same thing from a gzipped file rio('afile').nolines(0..9) > ary # ary will contain all but the first ten lines of the file rio('adir') > ary # ary will contain a Rio for each entry in the directory rio('adir').files > ary # same, but only files rio('adir').files('*.rb') >ary # same, but only .rb files </pre> <p> Copying to a string </p> <pre> rio('afile') > astring # slurp the entire contents of the file into astring astring = rio('afile').slurp # same effect </pre> <p> Copy the first line <b>and</b> every line containing the word <a href="Rio.html">Rio</a> into a gzipped file </p> <pre> rio('src').lines(1,/Rio/) > rio('dst.gz').gzip </pre> <p> Copy lines of a web page into an array with each line chomped </p> <pre> rio('http://ruby-doc.org/index.html').chomp > an_array </pre> <p> Copy the first and 8th through 10th columns of the first ten rows of a gzipped csv file on a web site into a local gzipped csv file that uses semi-colons as separators </p> <pre> rio('http://domain/file.csv.gz').columns(0,7..9).gzip.csv[0..9] > rio('localfile.csv.gz').csv(';').gzip </pre> </div> </div> <div id="method-M000049" class="method-detail"> <a name="M000049"></a> <div class="method-heading"> <a href="Rio.src/M000049.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000049.html');return false;"> <span class="method-name">>></span><span class="method-args">(destination)</span> </a> </div> <div class="method-description"> <p> Grande Append-To Operator </p> <p> The append-to grande-operator is the same as <a href="Rio.html">Rio</a>#> (copy-to) except that it opens the destination for append. The destination can be a kind of: </p> <table> <tr><td valign="top">IO:</td><td>Each record of the <a href="Rio.html">Rio</a> is written to the IO using IO#print. The IO must be opened for writing. </td></tr> <tr><td valign="top">Array:</td><td>Each record or entry of the <a href="Rio.html">Rio</a> is appended to the destination array </td></tr> <tr><td valign="top">String:</td><td>Appends the entire contents of the <a href="Rio.html">Rio</a> to destination </td></tr> <tr><td valign="top"><a href="Rio.html">Rio</a>:</td><td>Just like <a href="Rio.html">Rio</a>#> (copy-to) except the unopened object are opened for append. If the destination is already opened for writing or is a directory, this is identical to <a href="Rio.html">Rio</a>#> (copy-to) </td></tr> </table> <p> See <a href="Rio.html">Rio</a>#> (copy-to) </p> <pre> rio('afile') >> rio('anotherfile') # append the contents of 'afile' to 'anotherfile' rio('afile') >> rio('adir') # copies 'afile' to the directory 'adir' rio('adir') >> rio('anotherdir') # copy directory 'adir' recursively to 'anotherdir' rio('adir') >> array # appendscopy directory 'adir' recursively to 'anotherdir' rio('adir') >> ary # a Rio for each entry in the directory will be appended to ary </pre> </div> </div> <div id="method-M000044" class="method-detail"> <a name="M000044"></a> <div class="method-heading"> <a href="Rio.src/M000044.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000044.html');return false;"> <span class="method-name">[]</span><span class="method-args">(*selectors)</span> </a> </div> <div class="method-description"> <p> Grande subscript operator. </p> <p> For files this returns all or part of a file as an array. </p> <p> For directories this returns all or some of the entries in a directory </p> <h3>Files</h3> <p> This combines the record selection offered by <a href="Rio.html#M000057">Rio#records</a> with the conversion to an array provided by Rio#to_a. The following two are equivelant: </p> <ul> <li>ario[*args] </li> <li>ario.records(*args).to_a </li> </ul> <p> What constitutes an array element is determined by <a href="Rio.html#M000055">Rio#lines</a>, <a href="Rio.html#M000056">Rio#bytes</a>, or by an extension such as Rio#csv. <a href="Rio.html#M000055">Rio#lines</a> is the default. </p> <p> Arguments may consist of zero or more integers, ranges, regular expressions, symbols and procs. An empty argument list selects all records </p> <p> Records are selected as follows. </p> <table> <tr><td valign="top">range:</td><td>specifies a range of records to be selected (zero based) </td></tr> <tr><td valign="top">regexp:</td><td>matching records will be selected. </td></tr> <tr><td valign="top">integer:</td><td>treated like a one element range </td></tr> <tr><td valign="top">symbol:</td><td>the symbol is sent to the string. record is selected unless false is returned </td></tr> <tr><td valign="top">proc:</td><td>the proc is called with the string as an argument. record is selected unless false is returned </td></tr> </table> <p> A record matching <b>any</b> of the selectors will be included in the array. (acts like an <em>or</em>) </p> <p> Because this is implemented in terms of the <a href="Rio.html#M000045">Rio#each</a>, When only record ranges are used to select records, iteration will stop when the recno exceeds the maximum of any range. That is to say </p> <p> This reads one record from a file and returns it </p> <pre> rio('bigfile.mp3').bytes(1024)[0] </pre> <p> While this reads <b>all</b> records from a file and returns the first one </p> <pre> rio('bigfile.mp3').bytes(1024).to_a[0] </pre> <h3>Directories</h3> <p> This combines the entry selection offered by <a href="Rio.html#M000020">Rio#entries</a> with the conversion to an array provided by Rio#to_a. The following two are equivelant: </p> <ul> <li>ario[*args] </li> <li>ario.entries(*args).to_a </li> </ul> <p> Arguments may consist of strings (treated as globs) or regular expressions. An empty argument list selects all entries See ::Dir#glob and ::File::fnmatch? for more in information on <em>globs</em>. Be warned that using the ’**’ glob recurses into directories independently of <a href="Rio.html#M000024">Rio#all</a> and using both is unsupported. </p> <pre> ario = rio('adir') ario[] # returns an array containg all entries in _adir_ ario[/^zippy/] # all entries starting with 'zippy' ario['zippy*'] # same thing </pre> <p> As with <a href="Rio.html#M000045">Rio#each</a>: </p> <ul> <li>Files and directories are returned as Rios </li> <li>The types of entries is also affected by <a href="Rio.html#M000021">Rio#files</a> and <a href="Rio.html#M000018">Rio#dirs</a>. <pre> rio('adir').files['*.txt'] # array of all _.txt_ files rio('adir').dirs(/^\./) # array of all dot directories </pre> </li> <li>Recursion is enabled using <a href="Rio.html#M000024">Rio#all</a> <pre> rio('adir').all.files['*.[ch]'] # array of c source files in _adir_ and its subdirecories rio('adir').all.dirs[/^\.svn/] # array of subversion directories in _adir_ and subdirectories </pre> </li> <li><a href="Rio.html#M000021">Rio#files</a> and <a href="Rio.html#M000018">Rio#dirs</a> act independetly of each other. Specifying both will cause both to be returned. The argument list to <a href="Rio.html">Rio</a>#[] will be applied to the closest. <pre> rio('adir').files('*.rb').dirs['ruby*'] # array of _.rb_ files and # directories starting with 'ruby' rio('adir').dirs('ruby*').files['*.rb'] # same thing </pre> </li> </ul> <h3>Lines</h3> <p> This section applies similarly to <a href="Rio.html#M000055">Rio#lines</a>, <a href="Rio.html#M000056">Rio#bytes</a>, <a href="Rio.html#M000057">Rio#records</a>, and <a href="Rio.html#M000060">Rio#rows</a> </p> <p> Using <a href="Rio.html#M000055">Rio#lines</a> and related methods with a <a href="Rio.html">Rio</a> referencing a directory imples <a href="Rio.html#M000021">Rio#files</a> and will cause an array of the lines or bytes in the files to be returned. As above, the arguments to the subscript operator will be applied to the closest. </p> <pre> rio('adir').lines[] # array of all lines in the files in 'adir' rio('adir').files.lines[] # same thing rio('adir').lines(0..9).files['*.txt'] # array of the first ten lines of all .txt files rio('adir').files('*.txt').lines[0..9] # same thing rio('adir').all.files('*.rb').lines[/^\s*require/] # array of 'require' lines in .rb files in # 'adir and its subdirectories </pre> <p> Note the difference between the following similar usages </p> <pre> it1 = rio('adir').files('*.rb') # returns a Rio, prepared for selecting ruby files it2 = rio('adir').files['*.rb'] # returns an array of the ruby files </pre> <p> The second example above could have been written </p> <pre> it2 = it1.to_a </pre> <p> Examples: </p> <pre> rio('afile.txt').lines[1..2] # array containing the 2nd and 3rd line rio('afile.txt')[1,3..5] # array containing lines 1,3,4 and 5 rio('afile.txt')[/Zippy/] # array of all lines containing 'Zippy' rio('afile.txt')[1,3..5,/Zippy/] # array with lines 1,3,4 and 5 and all lines containing 'Zippy' rio('afile.dat').bytes(50)[] # array containing the contents of afile.dat broken up into 50 byte chunks rio('afile.dat').bytes(50)[0,2] # array containing the first and third such chunk rio('afile.dat').bytes(50).records[0,2] # same thing rio('afile.dat').bytes(50).records(0,2).to_a # once again rio('afile.csv').csv[0..9] # array of the first 10 records of afile.csv parsed by the ::CSV module rio('afile.csv').csv.records[0..9] # same thing rio('afile.csv').csv(';').records[0..9] # same thing using semi-colon as the value separator rio('afile.csv').csv.records[0,/Zippy/] # record 0 and all records containing 'Zippy' # the regexp is matched against the line before parsing by ::CSV rio('adir')[] # array of entries in 'adir' rio('adir')['*.txt'] # array of all .txt entries rio('adir').all['*.txt'] # array of all .txt entries in 'adir and its subdirectories rio('adir').files['*.txt'] # array of all .txt files rio('adir').dirs['CSV'] # array of all CSV directories rio('adir').nodirs['CSV'] # array of all non-CSV directories </pre> </div> </div> <div id="method-M000062" class="method-detail"> <a name="M000062"></a> <div class="method-heading"> <a href="Rio.src/M000062.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000062.html');return false;"> <span class="method-name">a</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Sets the implicit output mode to ‘a’. </p> <p> This is the mode <a href="Rio.html">Rio</a> will use for output when no mode is specified </p> <p> Rios normally don’t need to be opened or have their open mode specified. A <a href="Rio.html">Rio</a> determines the mode based on the file system object and on the action specified. For instance when a <a href="Rio.html">Rio</a> encounters a <tt>read</tt> on a file it opens the file for reading using File#open and calls IO#read; when it encounters a <tt>read</tt> on a directory it knows to use Dir#open and call Dir#read. When it encounters a <a href="Rio.html#M000132">Rio#puts</a>, it knows to perform a File#open, and call IO#puts on the returned handle. By default when a method requires a file be opened for writing the file is opened with a mode of ‘w’. <a href="Rio.html#M000062">Rio#a</a> changes this implicit output mode to ‘a’. </p> <p> Note that this is not the same as setting the output mode <b>explicitly</b>, as in rio(‘afile’).mode(‘a’). When the mode is set explicitly using <a href="Rio.html#M000139">Rio#mode</a>, the mode specified will be used regardless of the operation being performed. The <a href="Rio.html#M000062">Rio#a</a> method only affects how <a href="Rio.html">Rio</a> opens a file when it sees an operator that requires writing, and must determine for itself how to open it. </p> <pre> rio('afile').puts!('Hello World') # call IO#puts on a file handle opened in 'w' mode rio('afile').a.puts!('Hello World') # call IO#puts on a file handle opened in 'a' mode </pre> <p> See also <a href="Rio.html#M000062">Rio#a</a>!, <a href="Rio.html#M000066">Rio#w</a>! for setting the implicit output mode ‘a+’ and ‘w+’ respectively </p> <p> The methods <a href="Rio.html#M000062">Rio#a</a>, <a href="Rio.html#M000062">Rio#a</a>!, <a href="Rio.html#M000066">Rio#w</a>, <a href="Rio.html#M000066">Rio#w</a>!, <a href="Rio.html#M000064">Rio#r</a>, <a href="Rio.html#M000064">Rio#r</a>! set the <tt>implicit</tt> open mode to ‘a’,’a+’,’w’,’w+’,’r’ and ‘r+’ respectively. </p> </div> </div> <div id="method-M000063" class="method-detail"> <a name="M000063"></a> <div class="method-heading"> <a href="Rio.src/M000063.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000063.html');return false;"> <span class="method-name">a!</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Sets the implicit output mode to ‘a+’. </p> <p> The implicit output mode is the mode <a href="Rio.html">Rio</a> will use for output when no mode is specified. </p> <p> Returns the <a href="Rio.html">Rio</a> </p> <p> See the discussion for <a href="Rio.html#M000062">Rio#a</a>. </p> </div> </div> <div id="method-M000086" class="method-detail"> <a name="M000086"></a> <div class="method-heading"> <a href="Rio.src/M000086.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000086.html');return false;"> <span class="method-name">abs</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> Returns a new rio with a path equal to the absolute path of this rio </p> <pre> rio('/tmp').chdir rio('afile').abs # => rio('/tmp/afile') </pre> </div> </div> <div id="method-M000180" class="method-detail"> <a name="M000180"></a> <div class="method-heading"> <a href="Rio.src/M000180.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000180.html');return false;"> <span class="method-name">abs?</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Returns true if the rio represents and absolute path or URI. Alias for Rio#absolute? </p> <pre> rio('/tmp').abs? # >> true rio('.ssh').abs? # >> false rio('file:///tmp').abs? # >> true rio('http://www.ruby-doc.org/').abs? # >> true </pre> </div> </div> <div id="method-M000181" class="method-detail"> <a name="M000181"></a> <div class="method-heading"> <a href="Rio.src/M000181.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000181.html');return false;"> <span class="method-name">absolute?</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Returns true if the <a href="Rio.html">Rio</a> represents and absolute path or URI. Calls URI#absolute? </p> <pre> rio('/tmp').absolute? # >> true rio('.ssh').absolute? # >> false rio('file:///tmp').absolute? # >> true rio('http://www.ruby-doc.org/').absolute? # >> true </pre> </div> </div> <div id="method-M000024" class="method-detail"> <a name="M000024"></a> <div class="method-heading"> <a href="Rio.src/M000024.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000024.html');return false;"> <span class="method-name">all</span><span class="method-args">(arg=true,&block)</span> </a> </div> <div class="method-description"> <p> Grande Directory Recursion Method </p> <p> Sets the <a href="Rio.html">Rio</a> to all mode (recursive) </p> <p> When called with a block, behaves as if all.each(&block) had been called </p> <p> <tt>all</tt> causes subsequent calls to <tt>files</tt> or <tt>dirs</tt> to be applied recursively to subdirectories </p> <pre> rio('adir').all.files('*.[ch]').each { |file| ... } # process all c language source files in adir # and all subdirectories of adir rio('adir').all.files(/\.[ch]$/) { |file| ... } # same as above rio('adir').files("*.[ch]").all { |file| ... } # once again rio('adir').all.files["*.[ch]"] # same, but return an array instead of iterating </pre> </div> </div> <div id="method-M000023" class="method-detail"> <a name="M000023"></a> <div class="method-heading"> <a href="Rio.src/M000023.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000023.html');return false;"> <span class="method-name">all?</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Returns <tt>true</tt> if the rio is in <tt>all</tt> (recursive) mode. See <a href="Rio.html#M000024">Rio#all</a> </p> <pre> adir = rio('adir').all.dirs adir.all? # true adir.each do |subdir| subdir.all? # true end rio('adir').all? # false </pre> </div> </div> <div id="method-M000163" class="method-detail"> <a name="M000163"></a> <div class="method-heading"> <a href="Rio.src/M000163.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000163.html');return false;"> <span class="method-name">atime</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> Calls File#atime </p> <p> Returns the last access time (a Time object) for the file system object referenced </p> </div> </div> <div id="method-M000088" class="method-detail"> <a name="M000088"></a> <div class="method-heading"> <a href="Rio.src/M000088.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000088.html');return false;"> <span class="method-name">base</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Returns a new <a href="Rio.html">Rio</a> whose path is the base path that is used by <a href="Rio.html#M000086">Rio#abs</a> to create an absolute <a href="Rio.html">Rio</a> from a relative one. </p> <pre> rio('/tmp').chdir rio('afile').base # => rio('/tmp/') </pre> <p> See <a href="Rio.html#M000086">Rio#abs</a>. </p> </div> </div> <div id="method-M000092" class="method-detail"> <a name="M000092"></a> <div class="method-heading"> <a href="Rio.src/M000092.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000092.html');return false;"> <span class="method-name">basename</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> Similar to File#basename </p> <p> Returns a <a href="Rio.html">Rio</a> whose path is that returned by File#basename when passed the path of a rio and the value returned by File#extname. This differs from the behaviour of File#basename. </p> <pre> File.basename('afile.txt') #=> 'afile.txt' File.basename('afile.txt',File.extname('afile.txt')) #=> 'afile' rio('afile.txt').basename #=> rio('afile') rio('afile.txt').basename('.txt') #=> same thing rio('afile.txt').ext('.txt').basename #=> same thing </pre> <p> See also <a href="Rio.html#M000089">Rio#ext</a>,<a href="Rio.html#M000089">Rio#ext</a>?,<a href="Rio.html#M000095">Rio#filename</a>, </p> </div> </div> <div id="method-M000097" class="method-detail"> <a name="M000097"></a> <div class="method-heading"> <a href="Rio.src/M000097.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000097.html');return false;"> <span class="method-name">basename=</span><span class="method-args">(arg)</span> </a> </div> <div class="method-description"> <p> Replace the part of the path returned by <a href="Rio.html#M000092">Rio#basename</a>. If in <tt>rename</tt> mode, also renames the referenced filesystem object. </p> <p> Returns the new value of <tt>basename</tt> </p> <pre> ario = rio('dirA/dirB/afile.rb') ario.dirname = 'dirC' # rio('dirC/afile.rb') ario.basename = 'bfile' # rio('dirC/bfile.rb') ario.extname = '.txt' # rio('dirC/bfile.txt') ario.filename = 'cfile.rb' # rio('dirC/cfile.rb') rio('adir/afile.txt').rename.filename = 'bfile.rb' # adir/afile.txt => adir/bfile.rb rio('adir/afile.txt').rename.basename = 'bfile' # adir/afile.txt => adir/bfile.txt rio('adir/afile.txt').rename.extname = '.rb' # adir/afile.txt => adir/afile.rb rio('adir/afile.txt').rename.dirname = 'b/c' # adir/afile.txt => b/c/afile.txt </pre> <p> See <a href="Rio.html#M000092">Rio#basename</a>, <a href="Rio.html#M000037">Rio#rename</a> </p> </div> </div> <div id="method-M000120" class="method-detail"> <a name="M000120"></a> <div class="method-heading"> <a href="Rio.src/M000120.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000120.html');return false;"> <span class="method-name">binmode</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Calls IO#binmode </p> <p> Puts rio into binary mode. This is useful only in MS-DOS/Windows environments. Once a stream is in binary mode, it cannot be reset to nonbinary mode. </p> <p> Returns the <a href="Rio.html">Rio</a>. </p> <pre> rio('afile.exe').binmode.bytes(512).to_a # read a file in 512 byte blocks </pre> </div> </div> <div id="method-M000148" class="method-detail"> <a name="M000148"></a> <div class="method-heading"> <a href="Rio.src/M000148.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000148.html');return false;"> <span class="method-name">blockdev?</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Calls FileTest#blockdev? </p> <pre> rio('afile').blockdev? => true or false </pre> <p> Returns <tt>true</tt> if the named file is a block device. </p> </div> </div> <div id="method-M000056" class="method-detail"> <a name="M000056"></a> <div class="method-heading"> <a href="Rio.src/M000056.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000056.html');return false;"> <span class="method-name">bytes</span><span class="method-args">(n=1,*args,&block)</span> </a> </div> <div class="method-description"> <p> Sets the rio to read bytes and returns the rio </p> <p> <em>n</em> specifies the number of bytes to be returned on each iteration of <a href="Rio.html#M000045">Rio#each</a> or by <a href="Rio.html#M000052">Rio#getrec</a>. If <em>args</em> are provided, they are treated as record selectors as if <tt>ario.bytes(n).records(*args)</tt> had been called. See also <a href="Rio.html#M000057">Rio#records</a>, <a href="Rio.html#M000055">Rio#lines</a>, <a href="Rio.html#M000045">Rio#each</a>, <a href="Rio.html">Rio</a>#[] </p> <p> If called with a block behaves as if <tt>ario.bytes(n,*args).each(&block)</tt> had been called </p> <pre> rio('f.dat').bytes(1024) { |rec| ... } # iterate through f.txt 1024 bytes at a time rio('f.dat').bytes(1024).each { |rec| ... } # same as above rio('f.dat').bytes(1024,0..4) { |rec| ... } # iterate through the first five 1024 byte blocks rio('f.dat').bytes(64).to_a # return the contents of f.dat as an array of 64 byte chunks rio('f.dat').bytes(512).records(0,7..9) > rio('dfile.dat') # copy 512-byte blocks 0,7,8 and 9 to dfile.dat rio('f.dat').bytes(2048).records[0...10] # return an array containing the first 10 2K blocks of f.dat rio('f.dat').bytes(2048)[0...10] # same thing rio('f.dat').bytes { |bytestr| ... } # iterate over f.dat 1 byte at a time. rio('f.dat').bytes[0...100] # returns an array of the first 100 bytes of f.dat </pre> </div> </div> <div id="method-M000149" class="method-detail"> <a name="M000149"></a> <div class="method-heading"> <a href="Rio.src/M000149.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000149.html');return false;"> <span class="method-name">chardev?</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Calls FileTest#chardev? </p> <pre> rio('afile').chardev? => true or false </pre> <p> Returns <tt>true</tt> if the named file is a character device. </p> </div> </div> <div id="method-M000017" class="method-detail"> <a name="M000017"></a> <div class="method-heading"> <a href="Rio.src/M000017.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000017.html');return false;"> <span class="method-name">chdir</span><span class="method-args">(&block)</span> </a> </div> <div class="method-description"> <p> Calls Dir#chdir. </p> <p> Changes the current working directory of the process to the directory specified by the <a href="Rio.html">Rio</a>. Raises a SystemCallError (probably Errno::ENOENT) if the target directory does not exist or if the <a href="Rio.html">Rio</a> does not reference a directory. </p> <p> If a block is given changes to the directory specified by the rio for the length of the block and changes back outside the block </p> <p> Returns the <a href="Rio.html">Rio</a> </p> <pre> rio('/home').chdir # change the current working directory to /home # the working directory here is /home rio('/tmp/data/mydata').delete!.mkpath.chdir { # the working directory here is /tmp/data/mydata } # the working directory here is /home </pre> </div> </div> <div id="method-M000075" class="method-detail"> <a name="M000075"></a> <div class="method-heading"> <a href="Rio.src/M000075.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000075.html');return false;"> <span class="method-name">chomp</span><span class="method-args">(arg=true,&block)</span> </a> </div> <div class="method-description"> <p> Sets the <a href="Rio.html">Rio</a> to chomp lines and returns the <a href="Rio.html">Rio</a> </p> <p> When called with a block, behaves as if chomp.each(&block) had been called </p> <p> chomp causes lines returned by each, to_a, readlines, readline, gets, <a href="Rio.html#M000123">each_line</a> etc. to be chomped before iterated over or assigned </p> <pre> rio('f.txt').chomp.each { |line| ... } # Block is called with lines already chomped rio('f.txt').chomp { |line| ... } # same as above rio('f.txt').chomp.to_a # returns the lines of f.txt chomped rio('f.txt').chomp.lines(1..2).to_a # returns an array containg lines 1 and 2 of the file after being chomped This would have similar results to rio('f.txt').lines(1..2).to_a.map{ |line| line.chomp} rio('f.txt').lines(1..2).chomp.to_a # same as above rio('f.txt').chomp.readlines # returns the lines of f.txt chomped rio('f.txt').chomp.gets # returns the first line of 'f.txt' chomped rio('f.txt').chomp > an_array # copies the chomped lines of f.txt into an_array # fill an array with all the 'require' lines in all the .rb files (recursively) in adir # chomping each line an_array = [] rio('adir').chomp.all.files("*.rb") { |file| an_array << file.lines(/^\s*require/) } </pre> </div> </div> <div id="method-M000074" class="method-detail"> <a name="M000074"></a> <div class="method-heading"> <a href="Rio.src/M000074.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000074.html');return false;"> <span class="method-name">chomp?</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Queries the <a href="Rio.html">Rio</a>’s chomp-mode. See <a href="Rio.html#M000075">Rio#chomp</a>. </p> </div> </div> <div id="method-M000141" class="method-detail"> <a name="M000141"></a> <div class="method-heading"> <a href="Rio.src/M000141.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000141.html');return false;"> <span class="method-name">close</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Calls IO#close </p> <pre> ario.close => nil </pre> <p> Closes <em>ario</em> and flushes any pending writes to the operating system. The stream is unavailable for any further data operations; an <tt>IOError</tt> is raised if such an attempt is made. I/O streams are automatically closed when they are claimed by the garbage collector. </p> </div> </div> <div id="method-M000157" class="method-detail"> <a name="M000157"></a> <div class="method-heading"> <a href="Rio.src/M000157.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000157.html');return false;"> <span class="method-name">closed?</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Calls IO#closed? </p> <pre> ario.closed? => true or false </pre> <p> Returns <tt>true</tt> if <em>ario</em> is completely closed (for duplex streams, both reader and writer), <tt>false</tt> otherwise. </p> </div> </div> <div id="method-M000071" class="method-detail"> <a name="M000071"></a> <div class="method-heading"> <a href="Rio.src/M000071.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000071.html');return false;"> <span class="method-name">closeoncopy</span><span class="method-args">(arg=true,&block)</span> </a> </div> <div class="method-description"> <p> Set a <a href="Rio.html">Rio</a>’s closeoncopy mode </p> <pre> ario.closeoncopy(&block) => ario </pre> <p> <a href="Rio.html#M000071">Rio#closeoncopy</a> causes the <a href="Rio.html">Rio</a> being written to to be closed when using a grande copy operator. While <a href="Rio.html#M000068">Rio#closeoneof</a> causes all <a href="Rio.html">Rio</a>’s to be closed when reading to the end of file, it does not affect Rios being written to. <a href="Rio.html#M000071">Rio#closeoncopy</a> only affects the <a href="Rio.html">Rio</a> being written to and only when a grande copy operator is used. <tt>closeoncopy</tt> is on by default, with one exception. </p> <pre> dest = rio('destfile') dest < rio('srcfile') dest.closed? #=> true dest = rio('destfile').nocloseoncopy dest < rio('srcfile') dest.closed? #=> false dest.close # must be explicitly closed dest = rio('destfile') dest.print(rio('srcfile').slurp) dest.closed? #=> false (Rio#print is not a copy operator) dest.close </pre> <h4>The Exception</h4> <p> When a block is passed directly to the rio constructor <tt>closeoncopy</tt> is turned off. </p> <pre> rio('afile') { |file| file.closeoncopy? #=> false file < a_string file.closed? #=> false } # The file is now closed. See Rio#rio for more informatioin </pre> <h4>Why?</h4> <p> Some of my favorite <a href="Rio.html">Rio</a> idioms are its copy one-liners </p> <pre> rio('afile') < a_string # put a string into a file rio('afile') < an_array # put an array into a file rio('afile') < rio('anotherfile').lines(1..10) # copy the first 10 lines of anotherfile into afile rio('afile.gz').gzip < rio('anotherfile').lines(1..10) # same thing into a gzipped file </pre> <p> In each of these cases, ‘afile’ would remain open after the copy and furthermore since the destination <a href="Rio.html">Rio</a> was not saved in a variable, There is no way to close file. Without closeoncopy Something like this would be required: </p> <pre> ario = rio('afile') ario < something_else ario.close </pre> <p> Or this… </p> <pre> ario = rio('afile') < something_else ario.close </pre> <p> Or this… </p> <pre> (rio('afile') < something_else).close </pre> <p> One line, but ugly, and prone to error. </p> <p> What I want is this: </p> <pre> rio('afile') < something_else </pre> <p> Simple. I want to copy this to that, I point the arrow and it works. </p> <p> In perl the rio’s destructor would be called, because there are no remaining references to the <a href="Rio.html">Rio</a> However, it my understanding and experience that in Ruby the finalizer will not necessarily be called at this point. Calling all gurus: If I am missing something, and there is a way to make this work without closeoncopy, please contact the author. </p> </div> </div> <div id="method-M000073" class="method-detail"> <a name="M000073"></a> <div class="method-heading"> <a href="Rio.src/M000073.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000073.html');return false;"> <span class="method-name">closeoncopy?</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Query a <a href="Rio.html">Rio</a>’s closeoncopy mode </p> <pre> ario.closeoncopy? => true or false </pre> <p> See <a href="Rio.html#M000071">Rio#closeoncopy</a> </p> </div> </div> <div id="method-M000068" class="method-detail"> <a name="M000068"></a> <div class="method-heading"> <a href="Rio.src/M000068.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000068.html');return false;"> <span class="method-name">closeoneof</span><span class="method-args">(arg=true,&block)</span> </a> </div> <div class="method-description"> <p> Set the <a href="Rio.html">Rio</a>’s closeoneof mode. </p> <pre> ario.closeoneof(&block) => ario </pre> <p> <tt>closeoneof</tt> causes a <a href="Rio.html">Rio</a> to be closed automatically whenever the end of file is reached. This is handled at the IO level, and thus affects all methods that read from a rio (<a href="Rio.html#M000124">Rio#readlines</a>, Rio#to_a, <a href="Rio.html#M000045">Rio#each</a> <a href="Rio.html#M000114">Rio#gets</a> etc.) Because <tt>closeoneof</tt> must be on for many of <a href="Rio.html">Rio</a>’s most useful idioms, it is on by default. <tt>closeoneof</tt> can be turned off using <a href="Rio.html#M000069">Rio#nocloseoneof</a>. </p> <p> If a block is given behaves like <tt>ario.closeoneof.each(&block)</tt> had been called </p> <p> Returns the <a href="Rio.html">Rio</a> </p> <pre> ario = rio('afile') lines = ario.readlines ario.closed? #=> true ario = rio('afile').nocloseoneof lines = ario.readlines ario.closed? #=> false ario.close # must be explicitly closed </pre> <p> <tt>closeoneof</tt> is ignored by directory Rios, however, setting it on a directory <a href="Rio.html">Rio</a> causes each file <a href="Rio.html">Rio</a> returned while iterating to inherit the directory’s setting </p> <pre> rio('adir').files do |file| file.closeoneof? #=> true end rio('adir').files.nocloseoneof do |file| file.closeoneof? #=> false end rio('adir').files.nocloseoneof['*.rb'] # array of .rb file Rios in adir with closeoneof off drio = rio('adir').files frio1 = drio.read frio1.closeoneof? #=> true drio.nocloseoneof frio2 = drio.read frio2.closeoneof? #=> false </pre> </div> </div> <div id="method-M000070" class="method-detail"> <a name="M000070"></a> <div class="method-heading"> <a href="Rio.src/M000070.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000070.html');return false;"> <span class="method-name">closeoneof?</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Query a <a href="Rio.html">Rio</a>’s closeoneof mode </p> <pre> ario.closeoneof? => true or false </pre> <p> See <a href="Rio.html#M000068">Rio#closeoneof</a> and <a href="Rio.html#M000069">Rio#nocloseoneof</a> </p> <pre> ario = rio('afile') ario.closeoneof? #=> true lines = ario.to_a ario.closed? #=> true ario = rio('afile').nocloseoneof ario.closeoneof? #=> false lines = ario.to_a ario.closed? #=> false ario.close # must be explicitly closed </pre> </div> </div> <div id="method-M000116" class="method-detail"> <a name="M000116"></a> <div class="method-heading"> <a href="Rio.src/M000116.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000116.html');return false;"> <span class="method-name">contents</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Returns the contents of the rio as a string. See also <a href="Rio.html#M000115">Rio#slurp</a> </p> <pre> astring = rio('afile.txt').contents # copies the entire contents of afile.txt into astring </pre> <p> Alpha Note: Considering removing <a href="Rio.html#M000116">Rio#contents</a> and <a href="Rio.html#M000115">Rio#slurp</a> in favor of <tt>to_string</tt>. Is this the Ruby way? Is it too confusing with a <tt><a href="Rio.html#M000008">to_s</a></tt> and <tt>to_str</tt> already? Is it a good idea? </p> </div> </div> <div id="method-M000164" class="method-detail"> <a name="M000164"></a> <div class="method-heading"> <a href="Rio.src/M000164.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000164.html');return false;"> <span class="method-name">ctime</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> Calls File#ctime </p> <p> Returns the change time for Rios that reference file system object (that is, the time directory information about the file was changed, not the file itself). </p> </div> </div> <div id="method-M000046" class="method-detail"> <a name="M000046"></a> <div class="method-heading"> <a href="Rio.src/M000046.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000046.html');return false;"> <span class="method-name">delete</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> For a file <a href="Rio.html">Rio</a> <tt>delete</tt> calls FileUtils#rm. For a directory <a href="Rio.html">Rio</a> <tt>delete</tt> calls FileUtils#rmdir Returns the <a href="Rio.html">Rio</a>. If the <a href="Rio.html">Rio</a> does not exist, simply return the <a href="Rio.html">Rio</a>. </p> <pre> rio('afile,txt').delete # delete 'afile.txt' rio('adir').delete # delete adir rio('something').delete # delete something </pre> </div> </div> <div id="method-M000047" class="method-detail"> <a name="M000047"></a> <div class="method-heading"> <a href="Rio.src/M000047.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000047.html');return false;"> <span class="method-name">delete!</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> For a file <a href="Rio.html#M000046">Rio#delete</a>! calls FileUtils#rm. For a directory <a href="Rio.html#M000046">Rio#delete</a>! calls FileUtils#rmtree Returns the <a href="Rio.html">Rio</a>. If the rio does not exist, simply return itself. </p> <pre> rio('afile,txt').delete! # delete f.txt rio('adir').delete! # delete adir # create a directory, after deleting anything that previously had its name rio('adir/asubdir').delete!.mkpath </pre> <h4>Deleting Summary</h4> <ul> <li>To delete something only if it is not a directory use <a href="Rio.html#M000033">Rio#rm</a> </li> <li>To delete an empty directory use <a href="Rio.html#M000029">Rio#rmdir</a> </li> <li>To delete an entire directory tree use <a href="Rio.html#M000030">Rio#rmtree</a> </li> <li>To delete anything except a populated directory use <a href="Rio.html#M000046">Rio#delete</a> </li> <li>To delete anything use <a href="Rio.html#M000046">Rio#delete</a>! </li> </ul> <p> In all cases, deleting something that does not exist is considered successful </p> </div> </div> <div id="method-M000151" class="method-detail"> <a name="M000151"></a> <div class="method-heading"> <a href="Rio.src/M000151.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000151.html');return false;"> <span class="method-name">dir?</span><span class="method-args">()</span> </a> </div> <div class="method-description"> </div> </div> <div id="method-M000150" class="method-detail"> <a name="M000150"></a> <div class="method-heading"> <a href="Rio.src/M000150.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000150.html');return false;"> <span class="method-name">directory?</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Calls FileTest#directory? </p> <pre> rio('afile').directory? => true or false </pre> <p> Returns <tt>true</tt> if the named file is a directory, <tt>false</tt> otherwise. </p> </div> </div> <div id="method-M000093" class="method-detail"> <a name="M000093"></a> <div class="method-heading"> <a href="Rio.src/M000093.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000093.html');return false;"> <span class="method-name">dirname</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> Calls File#dirname </p> <p> Returns a new <a href="Rio.html">Rio</a> referencing the directory portion of a <a href="Rio.html">Rio</a>. </p> <pre> rio('/tmp/zippy.txt').dirname #=> rio('/tmp') </pre> </div> </div> <div id="method-M000098" class="method-detail"> <a name="M000098"></a> <div class="method-heading"> <a href="Rio.src/M000098.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000098.html');return false;"> <span class="method-name">dirname=</span><span class="method-args">(arg)</span> </a> </div> <div class="method-description"> <p> Replace the part of the path returned by <a href="Rio.html#M000093">Rio#dirname</a>. If in <tt>rename</tt> mode, also renames the referenced filesystem object. </p> <p> Returns the new value of <tt>dirname</tt> </p> <pre> ario = rio('dirA/dirB/afile.rb') ario.dirname = 'dirC' # rio('dirC/afile.rb') ario.basename = 'bfile' # rio('dirC/bfile.rb') ario.extname = '.txt' # rio('dirC/bfile.txt') ario.filename = 'cfile.rb' # rio('dirC/cfile.rb') rio('adir/afile.txt').rename.filename = 'bfile.rb' # adir/afile.txt => adir/bfile.rb rio('adir/afile.txt').rename.basename = 'bfile' # adir/afile.txt => adir/bfile.txt rio('adir/afile.txt').rename.extname = '.rb' # adir/afile.txt => adir/afile.rb rio('adir/afile.txt').rename.dirname = 'b/c' # adir/afile.txt => b/c/afile.txt </pre> <p> See <a href="Rio.html#M000093">Rio#dirname</a>, <a href="Rio.html#M000037">Rio#rename</a> </p> </div> </div> <div id="method-M000018" class="method-detail"> <a name="M000018"></a> <div class="method-heading"> <a href="Rio.src/M000018.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000018.html');return false;"> <span class="method-name">dirs</span><span class="method-args">(*args,&block)</span> </a> </div> <div class="method-description"> <p> Grande Directory Selection Method </p> <p> Sets the rio to return directories. <em>args</em> can be used to select which directories are returned. </p> <pre> ario.files(*args) do |f| f.directory? #=> true end </pre> <p> No aguments selects all directories. if <em>args</em> are: </p> <table> <tr><td valign="top">Regexp:</td><td>selects matching directories </td></tr> <tr><td valign="top">glob:</td><td>selects matching directories </td></tr> <tr><td valign="top">Proc:</td><td>called for each directory. the directory is processed unless the proc returns false </td></tr> <tr><td valign="top">Symbol:</td><td>sent to each directory. Each directory is processed unless the symbol returns false </td></tr> </table> <p> If a block is given, behaves like <tt>ario.dirs(*args).each(&block)</tt> </p> <p> See also <a href="Rio.html#M000021">Rio#files</a>, <a href="Rio.html#M000020">Rio#entries</a>, <a href="Rio.html#M000019">Rio#nodirs</a> </p> <pre> rio('adir').dirs { |frio| ... } # process all directories in 'adir' rio('adir').all.dirs { |frio| ... } # same thing recursively rio('adir').dirs(/^\./) { |frio| ...} # process dot directories rio('adir').dirs[/^\./] # return an array of dot directories rio('adir').dirs[:symlink?] # an array of symlinks to directories </pre> </div> </div> <div id="method-M000009" class="method-detail"> <a name="M000009"></a> <div class="method-heading"> <a href="Rio.src/M000009.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000009.html');return false;"> <span class="method-name">dup</span><span class="method-args">()</span> </a> </div> <div class="method-description"> </div> </div> <div id="method-M000045" class="method-detail"> <a name="M000045"></a> <div class="method-heading"> <a href="Rio.src/M000045.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000045.html');return false;"> <span class="method-name">each</span><span class="method-args">(*args,&block)</span> </a> </div> <div class="method-description"> <p> Iterate through a rio. Executes the block for each item selected for the <a href="Rio.html">Rio</a>. See <a href="Rio.html#M000055">Rio#lines</a>, <a href="Rio.html#M000057">Rio#records</a>, <a href="Rio.html#M000056">Rio#bytes</a>, <a href="Rio.html#M000021">Rio#files</a>, <a href="Rio.html#M000018">Rio#dirs</a>, <a href="Rio.html">Rio</a>#[] and Rio#to_a for more information on how records are selected and what kind of record is passed to the block. </p> <p> <a href="Rio.html#M000045">Rio#each</a> is the fundemental method for all the <a href="Rio.html">Rio</a> grande operators. Rio#to_a and the <a href="Rio.html">Rio</a> copy operators <a href="Rio.html">Rio</a>#< <a href="Rio.html">Rio</a>#<< <a href="Rio.html">Rio</a>#>> <a href="Rio.html">Rio</a>#> are all implemented in terms of <a href="Rio.html#M000045">Rio#each</a>. </p> <p> While <a href="Rio.html#M000045">Rio#each</a> is fundamental to a <a href="Rio.html">Rio</a>, it rarely needs actually be called because all the grande configuration methods will also take a block and call <a href="Rio.html#M000045">Rio#each</a> if one is given. So the existance of a block after many methods is taken as an implied <a href="Rio.html#M000045">Rio#each</a> </p> <p> For Rios that refer to directories, the item passed to the block is a <a href="Rio.html">Rio</a> refering to the directory entry. </p> <pre> rio('adir').files.each do |file| file.kind_of?(RIO::Rio) # true end </pre> <p> In addition, the <a href="Rio.html">Rio</a> passed to the block inherits certain attributes from the directory <a href="Rio.html">Rio</a>. </p> <pre> rio('adir').files.chomp.each do |file| # chomp is ignored for directories, file.each do |line| # chomp attribute is inherited by the file rio # .. line is chomped end end </pre> <p> <a href="Rio.html#M000045">Rio#each</a> returns the <a href="Rio.html">Rio</a> which called it. </p> <p> Here are a few illustrative examples </p> <ul> <li>Processing lines in a file <pre> rio('f.txt').each { |line| ... } # execute block for every line in the file rio('f.txt').lines.each { |line| ... } # same thing rio('f.txt').lines { |line| ... } # same thing rio('f.txt').chomp.each { |line| ... } # same as above with lines chomped rio('f.txt').chomp { |line| ... } # ditto rio('f.txt').lines.chomp { |line| ... } # ditto rio('f.txt').chomp.lines { |line| ... } # ditto rio('f.txt.gz').gzip.each { |line| ... } # execute block for every line in a gzipped file rio('f.txt.gz').gzip { |line| ... } # same thing rio('f.txt.gz').lines.gzip { |line| ... } # same thing rio('f.txt.gz').gzip.chomp { |line| ... } # chomp lines from a gzipped file rio('f.txt.gz').gzip.chomp.each { |line| ... } # ditto rio('f.txt.gz').chomp.lines.gzip { |line| ... } # ditto rio('f.txt').lines(0..9) { |line| ... } # execute block for the first 10 lines in the file rio('f.txt').lines(0..9).each { |line| ... } # same thing rio('f.txt').lines(/^\s*#/) { |line| ... } # execute block for comment-only lines rio('f.txt').lines(/^\s*#/).each { |line| ... } # same thing rio('f.txt').lines(0,/Rio/) { |line| ... } # execute block for the first line and # all lines containing 'Rio' rio('f.txt.gz').gzip.chomp.lines(0..1) { |line| ... } # first 2 lines chomped from a gzip file </pre> </li> <li>Processing a file a block at a time <pre> rio('f.dat').bytes(10).each { |data| ... } # process the file 10 bytes at a time rio('f.dat').bytes(10) { |data| ... } # same thing rio('f.dat').bytes(10).records(2,4) { |data| ... } # only 3rd and 5th ten-byte data-block rio('f.dat.gz').gzip.records(2,4).bytes(10) { |data| ... } # same from a gzipped file </pre> </li> <li>Iterating over directories <pre> rio('adir').each { |ent| ... } # execute the block for each entry in the directory 'adir' rio('adir').files.each { |file| ...} # only files rio('adir').files { |file| ...} # ditto rio('adir').all.files { |file| ...} # files, recurse into subdirectories rio('adir').dirs { |dir| ...} # only directories rio('adir').files('*.rb') { |file| ...} # only .rb files using a glob rio('adir').files(/\.rb$/) { |file| ...} # only .rb files using a regular expression rio('adir').all.files('*.rb') { |file| ...} # .rb files, recursing into subdirectories rio('adir').dirs(/^\./) { |dir| ... } # only dot directories rio('adir').dirs('/home/*') { |dir| ... } # home directories </pre> </li> </ul> <p> See <a href="Doc/HOWTO.html">RIO::Doc::HOWTO</a> and <a href="Doc/SYNOPSIS.html">RIO::Doc::SYNOPSIS</a> for more examples, and <a href="Doc/INTRO.html">RIO::Doc::INTRO</a> for further explanation. </p> </div> </div> <div id="method-M000122" class="method-detail"> <a name="M000122"></a> <div class="method-heading"> <a href="Rio.src/M000122.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000122.html');return false;"> <span class="method-name">each_byte</span><span class="method-args">(*args,&block)</span> </a> </div> <div class="method-description"> <p> Calls IO#each_byte </p> <pre> ario.each_byte {|byte| block } => ario </pre> <p> Calls the given block once for each byte (0..255) in <em>ario</em>, passing the byte as an argument. </p> </div> </div> <div id="method-M000123" class="method-detail"> <a name="M000123"></a> <div class="method-heading"> <a href="Rio.src/M000123.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000123.html');return false;"> <span class="method-name">each_line</span><span class="method-args">(*args,&block)</span> </a> </div> <div class="method-description"> <p> Calls IO#each_line </p> <pre> ario.each_line(sep_string=$/) {|line| block } => ario </pre> <p> Executes the block for every line in <em>ario</em>, where lines are separated by <em>sep_string</em>. </p> </div> </div> <div id="method-M000020" class="method-detail"> <a name="M000020"></a> <div class="method-heading"> <a href="Rio.src/M000020.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000020.html');return false;"> <span class="method-name">entries</span><span class="method-args">(*args,&block)</span> </a> </div> <div class="method-description"> <p> Grande Directory Entry Selection Method </p> <p> No aguments selects all entries. </p> <p> if <tt>args</tt> are: </p> <table> <tr><td valign="top">Regexp:</td><td>selects matching entries </td></tr> <tr><td valign="top">glob:</td><td>selects matching entries </td></tr> <tr><td valign="top">Proc:</td><td>called for each entry. the entry is processed unless the proc returns false </td></tr> <tr><td valign="top">Symbol:</td><td>sent to each entry. Each entry is processed unless the symbol returns false </td></tr> </table> <p> If a block is given, behaves like <tt>ario.etries(*args).each(&block)</tt> </p> <p> See also <a href="Rio.html#M000021">Rio#files</a>, <a href="Rio.html#M000018">Rio#dirs</a>, Rio#noentries </p> <pre> rio('adir').entries { |frio| ... } # process all entries in 'adir' rio('adir').all.entries { |frio| ... } # same thing recursively rio('adir').entries(/^\./) { |frio| ...} # process entries starting with a dot rio('adir').entries[/^\./] # return an array of all entries starting with a dot rio('adir').entries[:symlink?] # an array of symlinks in 'adir' </pre> </div> </div> <div id="method-M000136" class="method-detail"> <a name="M000136"></a> <div class="method-heading"> <a href="Rio.src/M000136.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000136.html');return false;"> <span class="method-name">eof?</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Calls IO#eof? </p> <pre> ario.eof => true or false </pre> <p> Returns true if <em>ario</em> is at end of file. The stream must be opened for reading or an <tt>IOError</tt> will be raised. </p> </div> </div> <div id="method-M000015" class="method-detail"> <a name="M000015"></a> <div class="method-heading"> <a href="Rio.src/M000015.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000015.html');return false;"> <span class="method-name">eql?</span><span class="method-args">(other)</span> </a> </div> <div class="method-description"> <p> Returns true if their String representations are eql? </p> </div> </div> <div id="method-M000166" class="method-detail"> <a name="M000166"></a> <div class="method-heading"> <a href="Rio.src/M000166.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000166.html');return false;"> <span class="method-name">executable?</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> Calls File#executable? </p> <p> Returns true if the file is executable by the effective user id of this process. </p> </div> </div> <div id="method-M000167" class="method-detail"> <a name="M000167"></a> <div class="method-heading"> <a href="Rio.src/M000167.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000167.html');return false;"> <span class="method-name">executable_real?</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> Calls File#executable_real? </p> <p> Returns true if the file is executable by the real user id of this process. </p> </div> </div> <div id="method-M000152" class="method-detail"> <a name="M000152"></a> <div class="method-heading"> <a href="Rio.src/M000152.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000152.html');return false;"> <span class="method-name">exist?</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Calls FileTest#exist? </p> <pre> rio('afile').exist?() => true or false </pre> <p> Returns <tt>true</tt> if the named file exists. </p> </div> </div> <div id="method-M000085" class="method-detail"> <a name="M000085"></a> <div class="method-heading"> <a href="Rio.src/M000085.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000085.html');return false;"> <span class="method-name">expand_path</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> Proxy for File#expand_path </p> <p> Converts a pathname to an absolute pathname. Relative paths are referenced from the current working directory of the process unless dir_string is given, in which case it will be used as the starting point. The given pathname may start with a ``~��, which expands to the process owner�s home directory (the environment variable HOME must be set correctly). ``~user�� expands to the named user�s home directory. </p> <p> Returns a <a href="Rio.html">Rio</a> representing the returned path </p> </div> </div> <div id="method-M000089" class="method-detail"> <a name="M000089"></a> <div class="method-heading"> <a href="Rio.src/M000089.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000089.html');return false;"> <span class="method-name">ext</span><span class="method-args">(arg=nil)</span> </a> </div> <div class="method-description"> <p> Sets the string that the <a href="Rio.html">Rio</a> considers an extension. The value will be used by subsequent calls to <a href="Rio.html#M000092">Rio#basename</a>. If called with no arguments resets its value to the value returned by File#extname. Returns the <a href="Rio.html">Rio</a> </p> <pre> ario = rio('afile.txt') ario.ext('.txt').basename #=> rio('afile') ario.ext('.zip').basename #=> rio('afile.txt') ario.ext.basename #=> rio('afile') ario.ext('').basename #=> rio('afile.txt') </pre> <p> See also <a href="Rio.html#M000089">Rio#ext</a>,<a href="Rio.html#M000089">Rio#ext</a>?,<a href="Rio.html#M000095">Rio#filename</a>, </p> </div> </div> <div id="method-M000091" class="method-detail"> <a name="M000091"></a> <div class="method-heading"> <a href="Rio.src/M000091.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000091.html');return false;"> <span class="method-name">ext?</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Returns the value of the <a href="Rio.html">Rio</a>’s ‘ext’ variable This defaults to the value returned by <a href="Rio.html#M000094">Rio#extname</a> and may be set by either calling <a href="Rio.html#M000089">Rio#ext</a> or by passing an argument <a href="Rio.html#M000092">Rio#basename</a> See also <a href="Rio.html#M000092">Rio#basename</a>, <a href="Rio.html#M000089">Rio#ext</a>, <a href="Rio.html#M000094">Rio#extname</a>, <a href="Rio.html#M000090">Rio#noext</a> </p> <pre> ario = rio('afile.txt') ario.ext? #=> '.txt' ario.ext('.txt').basename #=> rio('afile') ario.ext? #=> '.txt' ario.ext('.zip').basename #=> rio('afile.txt') ario.ext? #=> '.zip' ario.basename('.tar') #=> rio('afile.txt') ario.ext? #=> '.tar' ario.ext.basename #=> rio('afile') ario.ext? #=> '.txt' ario.noext.basename #=> rio('afile.txt') ario.ext? #=> '' </pre> </div> </div> <div id="method-M000094" class="method-detail"> <a name="M000094"></a> <div class="method-heading"> <a href="Rio.src/M000094.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000094.html');return false;"> <span class="method-name">extname</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> Calls File#extname </p> <p> Returns a String containing the path’s extension </p> <pre> rio('/tmp/zippy.txt').extname #=> rio('.txt') </pre> </div> </div> <div id="method-M000096" class="method-detail"> <a name="M000096"></a> <div class="method-heading"> <a href="Rio.src/M000096.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000096.html');return false;"> <span class="method-name">extname=</span><span class="method-args">(arg)</span> </a> </div> <div class="method-description"> <p> Replace the part of the path returned by <a href="Rio.html#M000094">Rio#extname</a>. If in <tt>rename</tt> mode, also renames the referenced filesystem object. </p> <p> Returns the extension </p> <pre> ario = rio('dirA/dirB/afile.rb') ario.extname = '.txt' # rio('dirC/bfile.txt') rio('adir/afile.txt').rename.extname = '.rb' # adir/afile.txt => adir/afile.rb </pre> <p> See <a href="Rio.html#M000094">Rio#extname</a>, <a href="Rio.html#M000037">Rio#rename</a> </p> </div> </div> <div id="method-M000142" class="method-detail"> <a name="M000142"></a> <div class="method-heading"> <a href="Rio.src/M000142.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000142.html');return false;"> <span class="method-name">fcntl</span><span class="method-args">(integer_cmd,arg)</span> </a> </div> <div class="method-description"> <p> Calls IO#fcntl </p> <pre> ario.fcntl(integer_cmd, arg) => integer </pre> <p> Provides a mechanism for issuing low-level commands to control or query file-oriented I/O streams. Arguments and results are platform dependent. If <em>arg</em> is a number, its value is passed directly. If it is a string, it is interpreted as a binary sequence of bytes (+Array#pack+ might be a useful way to build this string). On Unix platforms, see +fcntl(2)+ for details. Not implemented on all platforms. </p> </div> </div> <div id="method-M000153" class="method-detail"> <a name="M000153"></a> <div class="method-heading"> <a href="Rio.src/M000153.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000153.html');return false;"> <span class="method-name">file?</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Calls FileTest#file? </p> <pre> rio('afile').file? => true or false </pre> <p> Returns <tt>true</tt> if the named file exists and is a regular file. </p> </div> </div> <div id="method-M000095" class="method-detail"> <a name="M000095"></a> <div class="method-heading"> <a href="Rio.src/M000095.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000095.html');return false;"> <span class="method-name">filename</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Returns a new <a href="Rio.html">Rio</a> with all path information stripped away. This is similar to <a href="Rio.html#M000092">Rio#basename</a>, except that it always includes an extension if one exists </p> <pre> rio('apath/afile.txt').filename #=> rio('afile.txt') </pre> </div> </div> <div id="method-M000099" class="method-detail"> <a name="M000099"></a> <div class="method-heading"> <a href="Rio.src/M000099.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000099.html');return false;"> <span class="method-name">filename=</span><span class="method-args">(arg)</span> </a> </div> <div class="method-description"> <p> Replace the part of the path returned by <a href="Rio.html#M000095">Rio#filename</a>. If in <tt>rename</tt> mode, also renames the referenced filesystem object. </p> <p> Returns the new value of <tt>filename</tt> </p> <pre> ario = rio('dirA/dirB/afile.rb') ario.dirname = 'dirC' # rio('dirC/afile.rb') ario.basename = 'bfile' # rio('dirC/bfile.rb') ario.extname = '.txt' # rio('dirC/bfile.txt') ario.filename = 'cfile.rb' # rio('dirC/cfile.rb') rio('adir/afile.txt').rename.filename = 'bfile.rb' # adir/afile.txt => adir/bfile.rb rio('adir/afile.txt').rename.basename = 'bfile' # adir/afile.txt => adir/bfile.txt rio('adir/afile.txt').rename.extname = '.rb' # adir/afile.txt => adir/afile.rb rio('adir/afile.txt').rename.dirname = 'b/c' # adir/afile.txt => b/c/afile.txt </pre> <p> See <a href="Rio.html#M000095">Rio#filename</a>, <a href="Rio.html#M000037">Rio#rename</a> </p> </div> </div> <div id="method-M000144" class="method-detail"> <a name="M000144"></a> <div class="method-heading"> <a href="Rio.src/M000144.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000144.html');return false;"> <span class="method-name">fileno</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Calls IO#fileno </p> <pre> ario.fileno => fixnum ario.to_i => fixnum </pre> <p> Returns an integer representing the numeric file descriptor for <em>ario</em>. </p> </div> </div> <div id="method-M000021" class="method-detail"> <a name="M000021"></a> <div class="method-heading"> <a href="Rio.src/M000021.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000021.html');return false;"> <span class="method-name">files</span><span class="method-args">(*args,&block)</span> </a> </div> <div class="method-description"> <p> Grande File Selection Method </p> <p> Sets the rio to return files. <tt>args</tt> can be used to select which files are returned. </p> <pre> ario.files(*args) do |f| f.file? #=> true end </pre> <p> No aguments selects all files. </p> <p> If <tt>args</tt> are: </p> <table> <tr><td valign="top">Regexp:</td><td>selects matching files </td></tr> <tr><td valign="top">glob:</td><td>selects matching files </td></tr> <tr><td valign="top">Proc:</td><td>called for each file. the file is processed unless the proc returns false </td></tr> <tr><td valign="top">Symbol:</td><td>sent to each file. Each file is processed unless the symbol returns false </td></tr> </table> <p> If a block is given, behaves like <tt>ario.files(*args).each</tt> </p> <p> See also <a href="Rio.html#M000018">Rio#dirs</a>, <a href="Rio.html#M000020">Rio#entries</a>, <a href="Rio.html#M000022">Rio#nofiles</a> </p> <pre> rio('adir').files { |frio| ... } # process all files in 'adir' rio('adir').all.files { |frio| ... } # same thing recursively rio('adir').files('*.rb') { |frio| ...} # process .rb files rio('adir').files['*.rb'] # return an array of .rb files rio('adir').files[/\.rb$/] # same thing using a regular expression rio('adir').files[:symlink?] # an array of symlinks to files </pre> <p> For Rios that refer to files, +files(*args)+ causes the file to be processed only if it meets the criteria specified by the args. </p> <pre> rio('afile.z').files['*.z'] #=> [rio('afile.z')] rio('afile.q').files['*.z'] #=> [] </pre> <p> Example </p> <p> Problem: </p> <p> Need an array of all ruby programs in a directory and its subdirectories, skipping those in <em>subversion</em> (.svn) directories. For the purposes of this problem, a Ruby program is defined as a file ending with .rb or a file that is executable and whose shebang line contains ‘ruby’ </p> <pre> rio(path).norecurse('.svn').files['*.rb',proc{ |f| f.executable? and f[0] =~ /^#!.+ruby/ }] </pre> <p> Explanation: </p> <p> Create a <a href="Rio.html">Rio</a> for a directory </p> <pre> rio(path) </pre> <p> Specify that ’.svn’ directories should not be included in recursion. </p> <pre> rio(path).norecurse('.svn') </pre> <p> Select files </p> <pre> rio(path).norecurse('.svn').files </pre> <p> Limit to files ending with ’.rb’ </p> <pre> rio(path).norecurse('.svn').files('*.rb') </pre> <p> Also allow files that are both executable and whose first line is a shebang-ruby line </p> <pre> rio(path).norecurse('.svn').files('*.rb',proc{ |f| f.executable? and f[0] =~ /^#!.+ruby/ }) </pre> <p> Return an array rather than iterating thru them </p> <pre> rio(path).norecurse('.svn').files['*.rb',proc{ |f| f.executable? and f[0] =~ /^#!.+ruby/ }] </pre> </div> </div> <div id="method-M000027" class="method-detail"> <a name="M000027"></a> <div class="method-heading"> <a href="Rio.src/M000027.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000027.html');return false;"> <span class="method-name">find</span><span class="method-args">(*args,&block)</span> </a> </div> <div class="method-description"> <p> Calls Find#find </p> <p> Uses Find#find to find all entries recursively for a <a href="Rio.html">Rio</a> that specifies a directory. Note that there are other ways to recurse through a directory structure using a <a href="Rio.html">Rio</a>. See <a href="Rio.html#M000045">Rio#each</a> and <a href="Rio.html#M000024">Rio#all</a>. </p> <p> Calls the block passing a <a href="Rio.html">Rio</a> for each entry found. The <a href="Rio.html">Rio</a> inherits attrubutes from the directory <a href="Rio.html">Rio</a>. </p> <p> Returns itself </p> <pre> rio('adir').find { |entrio| puts "#{entrio}: #{entrio.file?}" } rio('adir').chomp.find do |entrio| next unless entrio.file? lines = entrio[0..10] # lines are chomped because 'chomp' was inherited end </pre> </div> </div> <div id="method-M000121" class="method-detail"> <a name="M000121"></a> <div class="method-heading"> <a href="Rio.src/M000121.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000121.html');return false;"> <span class="method-name">flush</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Calls IO#flush </p> <pre> ario.flush => ario </pre> <p> Flushes any buffered data within <em>ario</em> to the underlying operating system (note that this is Ruby internal buffering only; the OS may buffer the data as well). </p> </div> </div> <div id="method-M000158" class="method-detail"> <a name="M000158"></a> <div class="method-heading"> <a href="Rio.src/M000158.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000158.html');return false;"> <span class="method-name">fnmatch?</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> Calls File#fnmatch? </p> <p> Returns true if path matches against pattern </p> </div> </div> <div id="method-M000084" class="method-detail"> <a name="M000084"></a> <div class="method-heading"> <a href="Rio.src/M000084.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000084.html');return false;"> <span class="method-name">fspath</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> Returns the path for the <a href="Rio.html">Rio</a> on the underlying file system Returns nil if the <a href="Rio.html">Rio</a> is not on the filesystem (i.e. stdin: or http: Rios) </p> </div> </div> <div id="method-M000145" class="method-detail"> <a name="M000145"></a> <div class="method-heading"> <a href="Rio.src/M000145.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000145.html');return false;"> <span class="method-name">fsync</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Calls IO#fsync </p> <pre> ario.fsync => ario </pre> <p> Immediately writes all buffered data in <em>ario</em> to disk and return <em>ario</em>. Does nothing if the underlying operating system does not support _fsync(2)_. Note that <tt>fsync</tt> differs from using <a href="Rio.html#M000078">Rio#sync</a>. The latter ensures that data is flushed from Ruby’s buffers, but doesn’t not guarantee that the underlying operating system actually writes it to disk. </p> </div> </div> <div id="method-M000159" class="method-detail"> <a name="M000159"></a> <div class="method-heading"> <a href="Rio.src/M000159.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000159.html');return false;"> <span class="method-name">ftype</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> Calls File#ftype </p> <p> Identifies the type of the named file; the return string is one of ‘file�, ‘directory�, ‘characterSpecial�, ‘blockSpecial�, ‘fifo�, ‘link�, ‘socket�, or ‘unknown�. </p> </div> </div> <div id="method-M000052" class="method-detail"> <a name="M000052"></a> <div class="method-heading"> <a href="Rio.src/M000052.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000052.html');return false;"> <span class="method-name">getrec</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Reads and returns the next record from a <a href="Rio.html">Rio</a>, honoring the grande selection methods. </p> <p> Returns nil on end of file. </p> <p> See also <a href="Rio.html#M000057">Rio#records</a>, <a href="Rio.html#M000055">Rio#lines</a>, <a href="Rio.html#M000045">Rio#each</a>, <a href="Rio.html">Rio</a>#[] </p> <pre> ario = rio('afile').lines(10..12) line10 = ario.getrec line11 = ario.getrec line12 = ario.getrec a_nil = ario.getrec </pre> </div> </div> <div id="method-M000114" class="method-detail"> <a name="M000114"></a> <div class="method-heading"> <a href="Rio.src/M000114.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000114.html');return false;"> <span class="method-name">gets</span><span class="method-args">(sep_string=$/)</span> </a> </div> <div class="method-description"> <p> Calls IO#gets </p> <p> Reads the next line from the <a href="Rio.html">Rio</a>; lines are separated by sep_string. A separator of nil reads the entire contents, and a zero-length separator reads the input a paragraph at a time (two successive newlines in the input separate paragraphs). </p> <p> Returns nil if called at end of file. </p> <pre> astring = rio('afile.txt').gets # read the first line of afile.txt into astring </pre> </div> </div> <div id="method-M000028" class="method-detail"> <a name="M000028"></a> <div class="method-heading"> <a href="Rio.src/M000028.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000028.html');return false;"> <span class="method-name">glob</span><span class="method-args">(string,*args,&block)</span> </a> </div> <div class="method-description"> <p> Calls Dir#glob </p> <p> Returns the filenames found by expanding the pattern given in string, either as an array or as parameters to the block. In both cases the filenames are expressed as a <a href="Rio.html">Rio</a>. Note that this pattern is not a regexp (it�s closer to a shell glob). See File::fnmatch for details of file name matching and the meaning of the flags parameter. </p> </div> </div> <div id="method-M000174" class="method-detail"> <a name="M000174"></a> <div class="method-heading"> <a href="Rio.src/M000174.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000174.html');return false;"> <span class="method-name">grpowned?</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> Calls FileTest#grpowned? </p> <pre> rio('afile').grpowned? => true or false </pre> <p> Returns <tt>true</tt> if the named file exists and the effective group id of the calling process is the owner of the file. Returns <tt>false</tt> on Windows. </p> </div> </div> <div id="method-M000105" class="method-detail"> <a name="M000105"></a> <div class="method-heading"> <a href="Rio.src/M000105.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000105.html');return false;"> <span class="method-name">gsub</span><span class="method-args">(re,string)</span> </a> </div> <div class="method-description"> <p> Create a new <a href="Rio.html">Rio</a> referencing the result of applying String#gsub to the value returned by <a href="Rio.html#M000008">Rio#to_s</a>. So: </p> <pre> ario.gsub(re,string) </pre> <p> is equivelent to </p> <pre> rio(ario.to_s.gsub(re,string)) </pre> </div> </div> <div id="method-M000076" class="method-detail"> <a name="M000076"></a> <div class="method-heading"> <a href="Rio.src/M000076.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000076.html');return false;"> <span class="method-name">gzip</span><span class="method-args">(&block)</span> </a> </div> <div class="method-description"> <p> Sets the <a href="Rio.html">Rio</a> to gzip mode. </p> <pre> ario.gzip #=> ario </pre> <p> If applied to a <a href="Rio.html">Rio</a> that is being read from Reads through a <tt>Zlib::GzipReader</tt>; If applied to a <a href="Rio.html">Rio</a> that is being written to writes through a <tt>Zlib::GzipWriter</tt>. </p> <p> Returns the <a href="Rio.html">Rio</a> </p> <p> If a block is given, acts like <tt>ario.gzip.each(&block)</tt> </p> <pre> rio('afile') > rio('afile.gz').gzip # gzip a file rio('afile.gz').gzip < rio('afile') # same thing rio('afile.gz').gzip > rio('afile') # ungzip a file rio('afile') < rio('afile.gz').gzip # same thing rio('afile.gz').gzip.chomp { |line| ...} # process each chomped line of a gzipped file rio('afile.gz').gzip[0..9] # an array containing the first 10 lines of a gzipped file </pre> </div> </div> <div id="method-M000077" class="method-detail"> <a name="M000077"></a> <div class="method-heading"> <a href="Rio.src/M000077.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000077.html');return false;"> <span class="method-name">gzip?</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Queries the <a href="Rio.html">Rio</a>’s gzip-mode </p> <pre> ario.gzip? #=> true or false </pre> <p> See <a href="Rio.html#M000076">Rio#gzip</a> </p> </div> </div> <div id="method-M000014" class="method-detail"> <a name="M000014"></a> <div class="method-heading"> <a href="Rio.src/M000014.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000014.html');return false;"> <span class="method-name">hash</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Rios are hashed based on their String representation </p> </div> </div> <div id="method-M000109" class="method-detail"> <a name="M000109"></a> <div class="method-heading"> <a href="Rio.src/M000109.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000109.html');return false;"> <span class="method-name">host</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> Calls URI#host for Rios which have a URI. Otherwise raises NoMethodError. </p> <pre> rio('http://ruby-doc.org/').host #=> 'ruby-doc' </pre> </div> </div> <div id="method-M000005" class="method-detail"> <a name="M000005"></a> <div class="method-heading"> <a href="Rio.src/M000005.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000005.html');return false;"> <span class="method-name">initialize_copy</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> </div> </div> <div id="method-M000010" class="method-detail"> <a name="M000010"></a> <div class="method-heading"> <a href="Rio.src/M000010.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000010.html');return false;"> <span class="method-name">inspect</span><span class="method-args">()</span> </a> </div> <div class="method-description"> </div> </div> <div id="method-M000143" class="method-detail"> <a name="M000143"></a> <div class="method-heading"> <a href="Rio.src/M000143.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000143.html');return false;"> <span class="method-name">ioctl</span><span class="method-args">(integer_cmd,arg)</span> </a> </div> <div class="method-description"> <p> Calls IO#ioctl </p> <pre> ario.ioctl(integer_cmd, arg) => integer </pre> <p> Provides a mechanism for issuing low-level commands to control or query I/O devices. Arguments and results are platform dependent. If <em>arg</em> is a number, its value is passed directly. If it is a string, it is interpreted as a binary sequence of bytes. On Unix platforms, see +ioctl(2)+ for details. Not implemented on all platforms. </p> </div> </div> <div id="method-M000137" class="method-detail"> <a name="M000137"></a> <div class="method-heading"> <a href="Rio.src/M000137.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000137.html');return false;"> <span class="method-name">ioh</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> Provides direct access to the IO handle (as would be returned by ::IO#new) <b>with</b> filtering. Reading from and writing to this handle will be affected by such things as <a href="Rio.html#M000076">Rio#gzip</a> and <a href="Rio.html#M000075">Rio#chomp</a> if they were specified for the <a href="Rio.html">Rio</a>. </p> <p> Compare this with <a href="Rio.html#M000138">Rio#ios</a> </p> </div> </div> <div id="method-M000138" class="method-detail"> <a name="M000138"></a> <div class="method-heading"> <a href="Rio.src/M000138.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000138.html');return false;"> <span class="method-name">ios</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> Provides direct access to the IO handle (as would be returned by ::IO#new) Reading from and writing to this handle is <b>not</b> affected by such things as <a href="Rio.html#M000076">Rio#gzip</a> and <a href="Rio.html#M000075">Rio#chomp</a>. </p> <p> Compare this with <a href="Rio.html#M000137">Rio#ioh</a> </p> </div> </div> <div id="method-M000100" class="method-detail"> <a name="M000100"></a> <div class="method-heading"> <a href="Rio.src/M000100.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000100.html');return false;"> <span class="method-name">join</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> Creates new <a href="Rio.html">Rio</a> by adding args as additional directory components like File#join. </p> <pre> ario = rio('adir') brio = rio('b') crio = ario.join(brio) #=> rio('adir/b') ario = rio('adir') ario.join('b','c','d') #=> rio('ario/b/c/d') </pre> <p> See also <a href="Rio.html">Rio</a>#/ </p> </div> </div> <div id="method-M000106" class="method-detail"> <a name="M000106"></a> <div class="method-heading"> <a href="Rio.src/M000106.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000106.html');return false;"> <span class="method-name">join!</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> Changes a <a href="Rio.html">Rio</a> inplace by adding args as additional directory components like <a href="Rio.html#M000100">Rio#join</a>, </p> </div> </div> <div id="method-M000011" class="method-detail"> <a name="M000011"></a> <div class="method-heading"> <a href="Rio.src/M000011.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000011.html');return false;"> <span class="method-name">length</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Returns the length of the <a href="Rio.html">Rio</a>’s String representation </p> <p> To get the size of the underlying file system object use <a href="Rio.html#M000177">Rio#size</a> </p> </div> </div> <div id="method-M000117" class="method-detail"> <a name="M000117"></a> <div class="method-heading"> <a href="Rio.src/M000117.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000117.html');return false;"> <span class="method-name">lineno</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Calls IO#lineno </p> <p> Returns the current line number of a <a href="Rio.html">Rio</a>. </p> <p> The <a href="Rio.html">Rio</a> will be opened for reading if not already. lineno counts the number of times gets is called, rather than the number of newlines encountered — so lineno will only be accurate if the file is read exclusively with line-oriented methods (<a href="Rio.html#M000125">Rio#readline</a>, <a href="Rio.html#M000123">Rio#each_line</a>, <a href="Rio.html#M000114">Rio#gets</a> etc.) </p> <p> See also the $. variable and <a href="Rio.html#M000119">Rio#recno</a> </p> <pre> f = rio("testfile") f.lineno #=> 0 f.gets #=> "This is line one\n" f.lineno #=> 1 f.gets #=> "This is line two\n" f.lineno #=> 2 </pre> </div> </div> <div id="method-M000118" class="method-detail"> <a name="M000118"></a> <div class="method-heading"> <a href="Rio.src/M000118.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000118.html');return false;"> <span class="method-name">lineno=</span><span class="method-args">(integer)</span> </a> </div> <div class="method-description"> <p> Calls IO#lineno= </p> <pre> ario.lineno = integer => integer </pre> <p> Manually sets the current line number to the given value. +$.+ is updated only on the next read. </p> <p> f = rio("testfile") f.gets #=> "This is line one\n" $. #=> 1 f.lineno = 1000 f.lineno #=> 1000 $. # lineno of last read #=> 1 f.gets #=> "This is line two\n" $. # lineno of last read #=> 1001 </p> </div> </div> <div id="method-M000055" class="method-detail"> <a name="M000055"></a> <div class="method-heading"> <a href="Rio.src/M000055.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000055.html');return false;"> <span class="method-name">lines</span><span class="method-args">(*args,&block)</span> </a> </div> <div class="method-description"> <p> Sets the rio to read lines and returns the <a href="Rio.html">Rio</a> </p> <p> If called with a block behaves as if lines(*args).each(&block) had been called </p> <p> If args are provided they may be one or more of the following: </p> <table> <tr><td valign="top">Regexp:</td><td>any matching record will be processed </td></tr> <tr><td valign="top">Range:</td><td>specifies a range of records (zero-based) to be included </td></tr> <tr><td valign="top">Integer:</td><td>interpreted as a one element range of lines to be processed </td></tr> <tr><td valign="top">Proc:</td><td>a proc which will be called for each record, records are included unless nil or false is returned </td></tr> <tr><td valign="top">Symbol:</td><td>a symbol which will <em>sent</em> to each record, records are included unless nil or false is returned </td></tr> </table> <pre> rio('f.txt').lines(/^\s*#/) { |line| ... } # iterate over comment-only lines rio('f.txt').lines(/^\s*#/).each { |line| ... } # same as above rio('f.txt').lines(1,7..9) > rio('anotherfile.txt') # copy lines 1,7,8 and 9 to anotherfile.txt rio('f.txt').lines(1...3).to_a # return an array containing lines 1 and 2 of f.txt rio('f.txt').lines[1...3] # same thing </pre> </div> </div> <div id="method-M000161" class="method-detail"> <a name="M000161"></a> <div class="method-heading"> <a href="Rio.src/M000161.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000161.html');return false;"> <span class="method-name">lstat</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> Calls File#lstat </p> </div> </div> <div id="method-M000111" class="method-detail"> <a name="M000111"></a> <div class="method-heading"> <a href="Rio.src/M000111.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000111.html');return false;"> <span class="method-name">merge</span><span class="method-args">(other)</span> </a> </div> <div class="method-description"> <p> Calls URI#merge </p> <p> Merges two Rios. URI#merge does not document exactly what merging to URIs means. This appears to join the the paths with like <tt>other + path</tt>. See URI#merge for less information. </p> </div> </div> <div id="method-M000032" class="method-detail"> <a name="M000032"></a> <div class="method-heading"> <a href="Rio.src/M000032.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000032.html');return false;"> <span class="method-name">mkdir</span><span class="method-args">(*args,&block)</span> </a> </div> <div class="method-description"> <p> Calls FileUtils#mkdir </p> <p> Makes a new directory named by the <a href="Rio.html">Rio</a> with permissions specified by the optional parameter. The permissions may be modified by the value of File::umask </p> <p> Returns the <a href="Rio.html">Rio</a>. If the directory already exists, just returns the <a href="Rio.html">Rio</a>. </p> <pre> rio('adir').mkdir </pre> </div> </div> <div id="method-M000031" class="method-detail"> <a name="M000031"></a> <div class="method-heading"> <a href="Rio.src/M000031.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000031.html');return false;"> <span class="method-name">mkpath</span><span class="method-args">(&block)</span> </a> </div> <div class="method-description"> <p> Calls FileUtils#mkpath </p> <p> Makes a new directory named by the <a href="Rio.html">Rio</a> and any directories in its path that do not exist. </p> <p> Returns the <a href="Rio.html">Rio</a>. If the directory already exists, just returns the <a href="Rio.html">Rio</a>. </p> <pre> rio('adir/a/b').mkpath </pre> </div> </div> <div id="method-M000139" class="method-detail"> <a name="M000139"></a> <div class="method-heading"> <a href="Rio.src/M000139.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000139.html');return false;"> <span class="method-name">mode</span><span class="method-args">(m,*args)</span> </a> </div> <div class="method-description"> <p> Explicitly set the mode with which a <a href="Rio.html">Rio</a> will be opened. </p> <pre> ario.mode('r+') => ario </pre> <p> Normally one needs never open a <a href="Rio.html">Rio</a> or specify its mode — the mode is determined by the operation the <a href="Rio.html">Rio</a> is asked to perform. (i.e. <a href="Rio.html#M000126">Rio#print</a> requires write access, <a href="Rio.html#M000124">Rio#readlines</a> requires read access). However there are times when one wishes to be specific about the mode with which a <a href="Rio.html">Rio</a> will be opened. Note that explicitly setting the mode overrides all of <a href="Rio.html">Rio</a>’s internal mode logic. If a mode is specified via <a href="Rio.html#M000139">Rio#mode</a> or <a href="Rio.html#M000007">Rio#open</a> that mode will be used. Period. </p> <p> Returns the <a href="Rio.html">Rio</a>. </p> <p> See also <a href="Rio.html#M000139">Rio#mode</a>? </p> <p> If the mode is given as a String, it must be one of the values listed in the following table. </p> <pre> Mode | Meaning -----+-------------------------------------------------------- "r" | Read-only, starts at beginning of file (default mode). -----+-------------------------------------------------------- "r+" | Read-write, starts at beginning of file. -----+-------------------------------------------------------- "w" | Write-only, truncates existing file | to zero length or creates a new file for writing. -----+-------------------------------------------------------- "w+" | Read-write, truncates existing file to zero length | or creates a new file for reading and writing. -----+-------------------------------------------------------- "a" | Write-only, starts at end of file if file exists, | otherwise creates a new file for writing. -----+-------------------------------------------------------- "a+" | Read-write, starts at end of file if file exists, | otherwise creates a new file for reading and | writing. -----+-------------------------------------------------------- "b" | (DOS/Windows only) Binary file mode (may appear with | any of the key letters listed above). ario = rio('afile').mode('r+').nocloseoneof # file will be opened in r+ mode # don't want the file closed at eof ario.seek(apos).gets # read the string at apos in afile ario.rewind.gets # read the string at the beginning of the file ario.close </pre> <p> TODO: </p> <ul> <li>Add support for integer modes </li> </ul> </div> </div> <div id="method-M000140" class="method-detail"> <a name="M000140"></a> <div class="method-heading"> <a href="Rio.src/M000140.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000140.html');return false;"> <span class="method-name">mode?</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Query a <a href="Rio.html">Rio</a>’s mode </p> <pre> ario.mode? #=> a mode string </pre> <p> See <a href="Rio.html#M000139">Rio#mode</a> </p> <pre> ario = rio('afile') ario.puts("Hello World") ario.mode? #=> 'w' Rio#puts requires write access ario = rio('afile') ario.gets ario.mode? #=> 'r' Rio#gets requires read access ario = rio('afile').mode('w+').nocloseoneof ario.gets ario.mode? #=> 'w+' Set explictly </pre> </div> </div> <div id="method-M000165" class="method-detail"> <a name="M000165"></a> <div class="method-heading"> <a href="Rio.src/M000165.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000165.html');return false;"> <span class="method-name">mtime</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> Calls File#mtime </p> <p> Returns the modification time for <a href="Rio.html">Rio</a> that reference file system objects </p> </div> </div> <div id="method-M000072" class="method-detail"> <a name="M000072"></a> <div class="method-heading"> <a href="Rio.src/M000072.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000072.html');return false;"> <span class="method-name">nocloseoncopy</span><span class="method-args">(arg=false,&block)</span> </a> </div> <div class="method-description"> <p> Set a <a href="Rio.html">Rio</a>’s closeoncopy mode to false </p> <pre> ario.nocloseoncopy(&block) => ario </pre> <p> See <a href="Rio.html#M000071">Rio#closeoncopy</a> </p> </div> </div> <div id="method-M000069" class="method-detail"> <a name="M000069"></a> <div class="method-heading"> <a href="Rio.src/M000069.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000069.html');return false;"> <span class="method-name">nocloseoneof</span><span class="method-args">(arg=false,&block)</span> </a> </div> <div class="method-description"> <p> Set the <a href="Rio.html">Rio</a>’s closeoneof mode to false </p> <pre> ario.nocloseoneof(&block) => ario </pre> <p> See <a href="Rio.html#M000068">Rio#closeoneof</a> </p> <p> If a block is given behaves like </p> <pre> ario.nocloseoneof.each(&block) </pre> <p> Returns the <a href="Rio.html">Rio</a> </p> <pre> ario = rio('afile') lines = ario.to_a ario.closed? #=> true ario = rio('afile').nocloseoneof lines = ario.to_a ario.closed? #=> false ario.close # must be explicitly closed </pre> </div> </div> <div id="method-M000019" class="method-detail"> <a name="M000019"></a> <div class="method-heading"> <a href="Rio.src/M000019.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000019.html');return false;"> <span class="method-name">nodirs</span><span class="method-args">(*args,&block)</span> </a> </div> <div class="method-description"> <p> Grande Directory Exclude Method </p> <p> If no args are provided selects anything but directories. </p> <pre> ario.nodirs do |el| el.directory? #=> false end </pre> <p> If args are provided, sets the rio to select directories as with <a href="Rio.html#M000018">Rio#dirs</a>, but the arguments are used to determine which directories will <b>not</b> be processed </p> <p> If a block is given behaves like </p> <pre> ario.nodirs(*args).each(&block) </pre> <p> See <a href="Rio.html#M000018">Rio#dirs</a> </p> <pre> rio('adir').nodirs { |ent| ... } # iterate through everything except directories rio('adir').nodirs(/^\./) { |drio| ... } # iterate through directories, skipping dot directories </pre> </div> </div> <div id="method-M000090" class="method-detail"> <a name="M000090"></a> <div class="method-heading"> <a href="Rio.src/M000090.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000090.html');return false;"> <span class="method-name">noext</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Identical to <a href="Rio.html#M000089">Rio#ext</a>(’’) See <a href="Rio.html#M000089">Rio#ext</a> </p> <pre> ario.basename #=> rio('afile') ario.noext.basename #=> rio('afile.txt') </pre> </div> </div> <div id="method-M000022" class="method-detail"> <a name="M000022"></a> <div class="method-heading"> <a href="Rio.src/M000022.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000022.html');return false;"> <span class="method-name">nofiles</span><span class="method-args">(*args,&block)</span> </a> </div> <div class="method-description"> <p> Grande File Exclude Method </p> <p> If no args are provided selects anything but files. </p> <pre> ario.nofiles do |el| el.file? #=> false end </pre> <p> If args are provided, sets the rio to select files as with <a href="Rio.html#M000021">Rio#files</a>, but the arguments are used to determine which files will <b>not</b> be processed </p> <p> If a block is given behaves like <tt>ario.nofiles(*args).each(&block)</tt> </p> <p> See <a href="Rio.html#M000021">Rio#files</a> </p> <pre> rio('adir').nofiles { |ent| ... } # iterate through everything except files rio('adir').nofiles(*~) { |frio| ... } # iterate through files, skipping those ending with a tilde </pre> </div> </div> <div id="method-M000059" class="method-detail"> <a name="M000059"></a> <div class="method-heading"> <a href="Rio.src/M000059.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000059.html');return false;"> <span class="method-name">nolines</span><span class="method-args">(*args,&block)</span> </a> </div> <div class="method-description"> <p> Sets the <a href="Rio.html">Rio</a> to read lines and specifies lines which should <b>not</b> be iterated through by <a href="Rio.html#M000045">Rio#each</a> or returned by <a href="Rio.html#M000052">Rio#getrec</a> </p> <p> If called with a block behaves as if <tt>nolines(*args).each(&block)</tt> had been called </p> <p> Returns the <a href="Rio.html">Rio</a> </p> <p> See also <a href="Rio.html#M000055">Rio#lines</a>, <a href="Rio.html#M000057">Rio#records</a> </p> <p> If no args are provided, no lines are rejected. </p> <p> If args are provided they may be one or more of the following: </p> <dl> <dt>Regexp</dt><dd>any matching line will not be processed </dd> <dt>Integer</dt><dd>specifies a line-number (zero-based) to be skipped </dd> <dt>Range</dt><dd>specifies a range of lines (zero-based) to be excluded </dd> <dt>Proc</dt><dd>a proc which will be called for each line, lines are excluded unless nil or false is returned </dd> <dt>Symbol</dt><dd>a symbol which will <em>sent</em> to each line, lines are excluded unless nil or false is returned </dd> </dl> <pre> rio('afile').nolines(0) { |line| ... } # iterate over all but the first line of 'afile' rio('afile').nolines(0,5..7)) { |line| ... } # don't iterate over lines 0,5,6 and 7 rio('afile').nolines(/Zippy/) { |line| ... } # skip all lines containing 'Zippy' rio('afile').chomp.nolines(:empty?) { |line| ... } # skip empty lines </pre> </div> </div> <div id="method-M000058" class="method-detail"> <a name="M000058"></a> <div class="method-heading"> <a href="Rio.src/M000058.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000058.html');return false;"> <span class="method-name">norecords</span><span class="method-args">(*args,&block)</span> </a> </div> <div class="method-description"> <p> Specifies records which should <b>not</b> be iterated through by <a href="Rio.html#M000045">Rio#each</a> or returned by <a href="Rio.html#M000052">Rio#getrec</a> </p> <p> If called with a block behaves as if norecords(*args).each(&block) had been called </p> <p> Returns the <a href="Rio.html">Rio</a> </p> <p> See also <a href="Rio.html#M000057">Rio#records</a>, <a href="Rio.html#M000059">Rio#nolines</a>, <a href="Rio.html#M000055">Rio#lines</a> </p> <p> If no args are provided, no records are rejected. What constitutes a record is affected by <a href="Rio.html#M000055">Rio#lines</a>,<a href="Rio.html#M000056">Rio#bytes</a>, and extensions such as Rio#csv. </p> <p> If args are provided they may be one or more of the following: </p> <table> <tr><td valign="top">Regexp:</td><td>any matching record will not be processed </td></tr> <tr><td valign="top">Integer:</td><td>specifies a record-number (zero-based) to be skipped </td></tr> <tr><td valign="top">Range:</td><td>specifies a range of records (zero-based) to be excluded </td></tr> <tr><td valign="top">Proc:</td><td>a proc which will be called for each record, records are excluded unless nil or false is returned </td></tr> <tr><td valign="top">Symbol:</td><td>a symbol which will <em>sent</em> to each record, records are excluded unless nil or false is returned </td></tr> </table> <p> Note in the following examples that since <tt>lines</tt> is the default record type <tt>ario.norecords(*args)</tt> is effectively the same as <tt>ario.nolines(*args)</tt>. </p> <pre> rio('afile').norecords(0) { |line| ... } # iterate over all but the first line of 'afile' rio('afile').norecords(0,5..7)) { |line| ... } # don't iterate over lines 0,5,6 and 7 rio('afile').norecords(/Zippy/) { |line| ... } # skip all lines containing 'Zippy' rio('afile').chomp.nolines(:empty?) { |line| ... } # skip empty lines </pre> </div> </div> <div id="method-M000026" class="method-detail"> <a name="M000026"></a> <div class="method-heading"> <a href="Rio.src/M000026.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000026.html');return false;"> <span class="method-name">norecurse</span><span class="method-args">(*args,&block)</span> </a> </div> <div class="method-description"> <p> Grande Directory Recursion Exclude Method </p> <p> Sets the <a href="Rio.html">Rio</a> to recurse into directories like <a href="Rio.html#M000024">Rio#all</a>. If no args are provided, no directories will be recursed into. If args are provided, behaves like <a href="Rio.html#M000025">Rio#recurse</a>, except that mathcing will <b>not</b> be recursed into </p> <pre> rio('adir').norecurse('.svn') { |drio| ... } # recurse, skipping subversion directories </pre> </div> </div> <div id="method-M000061" class="method-detail"> <a name="M000061"></a> <div class="method-heading"> <a href="Rio.src/M000061.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000061.html');return false;"> <span class="method-name">norows</span><span class="method-args">(*args,&block)</span> </a> </div> <div class="method-description"> <p> Sets the <a href="Rio.html">Rio</a> to read rows and specifies lines which should <b>not</b> be iterated through by <a href="Rio.html#M000045">Rio#each</a> or returned by <a href="Rio.html#M000052">Rio#getrec</a> <a href="Rio.html#M000061">Rio#norows</a> is intended for use by extensions, where the concept of a row is reasonable. In the absensence of an extension behaves like <a href="Rio.html#M000058">Rio#norecords</a> </p> </div> </div> <div id="method-M000079" class="method-detail"> <a name="M000079"></a> <div class="method-heading"> <a href="Rio.src/M000079.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000079.html');return false;"> <span class="method-name">nosync</span><span class="method-args">(arg=false,&block)</span> </a> </div> <div class="method-description"> <p> Similar to IO#sync= false </p> <pre> ario.nosync(&block) => ario </pre> <p> Sets the <a href="Rio.html">Rio</a> so that its ‘sync mode’ will be set to <tt>false</tt> when opened, or set it immediatly if already open. When sync mode is true, all output is immediately flushed to the underlying operating system and is not buffered internally. Returns the rio. See also <a href="Rio.html#M000145">Rio#fsync</a>, <a href="Rio.html#M000078">Rio#sync</a>, <a href="Rio.html#M000078">Rio#sync</a>?. </p> <p> If a block is given behaves like <tt>ario.nosync.each(&block)</tt> </p> <pre> f = rio("testfile").sync.puts("Hello World") f.sync? # => true f.nosync f.sync? # => false </pre> </div> </div> <div id="method-M000110" class="method-detail"> <a name="M000110"></a> <div class="method-heading"> <a href="Rio.src/M000110.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000110.html');return false;"> <span class="method-name">opaque</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> Calls URI#opaque for Rios which have URI representations. The opaque portion of a URI is the portion after the colon and before the question-mark beginning the query. </p> <pre> rio('http://example.org/do.cgi?n=1').opaque #=> '//example.org/do.cgi' </pre> <p> For Rios that do not have URL representations, returns the same part of <a href="Rio.html">Rio</a>’s internal psuedo-URL </p> </div> </div> <div id="method-M000007" class="method-detail"> <a name="M000007"></a> <div class="method-heading"> <a href="Rio.src/M000007.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000007.html');return false;"> <span class="method-name">open</span><span class="method-args">(m,*args) {|nocloseoncopy.nocloseoneof| ...}</span> </a> </div> <div class="method-description"> </div> </div> <div id="method-M000156" class="method-detail"> <a name="M000156"></a> <div class="method-heading"> <a href="Rio.src/M000156.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000156.html');return false;"> <span class="method-name">open?</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Returns <tt>true</tt> if a <a href="Rio.html">Rio</a> is not closed? </p> </div> </div> <div id="method-M000173" class="method-detail"> <a name="M000173"></a> <div class="method-heading"> <a href="Rio.src/M000173.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000173.html');return false;"> <span class="method-name">owned?</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> Calls FileTest#owned? </p> <pre> rio('afile').owned? => true or false </pre> <p> Returns <tt>true</tt> if the named file exists and the effective used id of the calling process is the owner of the file. </p> </div> </div> <div id="method-M000081" class="method-detail"> <a name="M000081"></a> <div class="method-heading"> <a href="Rio.src/M000081.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000081.html');return false;"> <span class="method-name">path</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> Returns the path for the <a href="Rio.html">Rio</a>, which is defined differently for different types of Rios. </p> <p> For Rios representing paths on the underlying file system this returns URI::FILE#path or URI::Generic#path depending on whether the <a href="Rio.html">Rio</a> is absolute or not. Note that this is not necessarily the same as <a href="Rio.html#M000084">Rio#fspath</a>, but rather a URL path as defined in RFC1738. </p> <p> For Rios that have a URI representation this returns URI#path </p> <p> Otherwise this returns nil. </p> </div> </div> <div id="method-M000162" class="method-detail"> <a name="M000162"></a> <div class="method-heading"> <a href="Rio.src/M000162.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000162.html');return false;"> <span class="method-name">pipe?</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Calls FileTest#pipe? </p> <pre> rio('afile').pipe? => true or false </pre> <p> Returns <tt>true</tt> if the named file is a pipe. </p> </div> </div> <div id="method-M000041" class="method-detail"> <a name="M000041"></a> <div class="method-heading"> <a href="Rio.src/M000041.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000041.html');return false;"> <span class="method-name">pos</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> For directories proxies Dir#pos, otherwise proxies IO#pos </p> <p> Proxy for IO#pos </p> <pre> ario.pos => integer ario.tell => integer </pre> <p> Returns the current offset (in bytes) of <em>ario</em>. </p> <pre> f = rio("testfile") f.pos #=> 0 f.gets #=> "This is line one\n" f.pos #=> 17 </pre> <p> Proxy for Dir#pos </p> <pre> ario.pos => integer ario.tell => integer </pre> <p> Returns the current position in <em>dir</em>. See also +<a href="Rio.html#M000040">Rio#seek</a>+. </p> <pre> d = rio("testdir") d.pos #=> 0 d.read #=> rio(".") d.pos #=> 12 </pre> </div> </div> <div id="method-M000043" class="method-detail"> <a name="M000043"></a> <div class="method-heading"> <a href="Rio.src/M000043.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000043.html');return false;"> <span class="method-name">pos=</span><span class="method-args">(integer)</span> </a> </div> <div class="method-description"> <p> For directories proxies Dir#pos=, otherwise proxies IO#pos= </p> <p> Proxy for IO#pos= </p> <pre> ario.pos = integer => 0 </pre> <p> Seeks to the given position (in bytes) in <em>ario</em>. </p> <pre> f = rio("testfile") f.pos = 17 f.gets #=> "This is line two\n" </pre> <p> Proxy for Dir#pos= </p> <pre> ario.pos = integer => integer </pre> </div> </div> <div id="method-M000126" class="method-detail"> <a name="M000126"></a> <div class="method-heading"> <a href="Rio.src/M000126.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000126.html');return false;"> <span class="method-name">print</span><span class="method-args">(*args,&block)</span> </a> </div> <div class="method-description"> <p> Calls IO::print </p> <p> Writes the given object(s) to the <a href="Rio.html">Rio</a>. If the output record separator ($\) is not nil, it will be appended to the output. If no arguments are given, prints $_. Objects that aren’t strings will be converted by calling their <a href="Rio.html#M000008">to_s</a> method. Returns the <a href="Rio.html">Rio</a>. </p> <pre> rio('f.txt').print("Hello Rio\n") # print the string to f.txt rio(?-).print("Hello Rio\n") # print the string to stdout </pre> </div> </div> <div id="method-M000127" class="method-detail"> <a name="M000127"></a> <div class="method-heading"> <a href="Rio.src/M000127.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000127.html');return false;"> <span class="method-name">print!</span><span class="method-args">(*args,&block)</span> </a> </div> <div class="method-description"> <p> Writes the given objects to the rio as with <a href="Rio.html#M000126">Rio#print</a> and then closes the <a href="Rio.html">Rio</a>. Returns the <a href="Rio.html">Rio</a>. </p> <p> Equivalent to rio.print(*args).close </p> <pre> rio('f.txt').print!("Hello Rio\n") # print the string to f.txt then close it </pre> </div> </div> <div id="method-M000129" class="method-detail"> <a name="M000129"></a> <div class="method-heading"> <a href="Rio.src/M000129.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000129.html');return false;"> <span class="method-name">printf</span><span class="method-args">(*argv)</span> </a> </div> <div class="method-description"> <p> Calls IO#printf </p> <pre> ario.printf(format_string [, obj, ...] ) => ario </pre> <p> Formats and writes to <em>ario</em>, converting parameters under control of the format string. See +Kernel#sprintf+ for details. </p> </div> </div> <div id="method-M000128" class="method-detail"> <a name="M000128"></a> <div class="method-heading"> <a href="Rio.src/M000128.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000128.html');return false;"> <span class="method-name">printf!</span><span class="method-args">(*argv)</span> </a> </div> <div class="method-description"> <p> Writes the given objects to the rio as with <a href="Rio.html#M000129">Rio#printf</a> and then closes the rio. Returns the rio. </p> <p> Equivalent to rio.printf(*args).close </p> </div> </div> <div id="method-M000131" class="method-detail"> <a name="M000131"></a> <div class="method-heading"> <a href="Rio.src/M000131.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000131.html');return false;"> <span class="method-name">putc</span><span class="method-args">(*argv)</span> </a> </div> <div class="method-description"> <p> Calls IO#putc </p> <pre> ario.putc(obj) => ario </pre> <p> If <em>obj</em> is <tt>Numeric</tt>, write the character whose code is <em>obj</em>, otherwise write the first character of the string representation of <em>obj</em> to <em>ario</em>. </p> <pre> stdout = rio(?-) stdout.putc "A" stdout.putc 65 </pre> <p> _produces:_ </p> <pre> AA </pre> </div> </div> <div id="method-M000130" class="method-detail"> <a name="M000130"></a> <div class="method-heading"> <a href="Rio.src/M000130.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000130.html');return false;"> <span class="method-name">putc!</span><span class="method-args">(*argv)</span> </a> </div> <div class="method-description"> <p> Writes the given objects to the rio as with <a href="Rio.html#M000131">Rio#putc</a> and then closes the rio. Returns the rio. </p> <p> Equivalent to rio.putc(*args).close </p> </div> </div> <div id="method-M000132" class="method-detail"> <a name="M000132"></a> <div class="method-heading"> <a href="Rio.src/M000132.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000132.html');return false;"> <span class="method-name">puts</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> Calls IO#puts </p> <p> Writes the given objects to the rio as with <a href="Rio.html#M000126">Rio#print</a> . Writes a record separator (typically a newline) after any that do not already end with a newline sequence. If called with an array argument, writes each element on a new line. If called without arguments, outputs a single record separator. Returns the rio. </p> </div> </div> <div id="method-M000133" class="method-detail"> <a name="M000133"></a> <div class="method-heading"> <a href="Rio.src/M000133.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000133.html');return false;"> <span class="method-name">puts!</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> Writes the given objects to the rio as with <a href="Rio.html#M000132">Rio#puts</a> and then closes the rio. Returns the rio. </p> <p> Equivalent to rio.puts(*args).close </p> <pre> rio('f.txt').puts!('Hello Rio') # print the string to f.txt then close it </pre> </div> </div> <div id="method-M000064" class="method-detail"> <a name="M000064"></a> <div class="method-heading"> <a href="Rio.src/M000064.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000064.html');return false;"> <span class="method-name">r</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Sets the implicit input mode to ‘r’. </p> <p> The implicit input mode is the mode <a href="Rio.html">Rio</a> will use for input when no mode is specified. </p> <p> Returns the <a href="Rio.html">Rio</a> </p> <p> See the discussion for <a href="Rio.html#M000062">Rio#a</a>. </p> <p> Since ‘r’ is the implicit input mode used by default, this method is probably uneeded. </p> </div> </div> <div id="method-M000065" class="method-detail"> <a name="M000065"></a> <div class="method-heading"> <a href="Rio.src/M000065.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000065.html');return false;"> <span class="method-name">r!</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Sets the implicit input mode to ‘r+’. </p> <p> The implicit input mode is the mode <a href="Rio.html">Rio</a> will use for input when no mode is specified. </p> <p> Returns the <a href="Rio.html">Rio</a> </p> <p> See the discussion for <a href="Rio.html#M000062">Rio#a</a>. </p> </div> </div> <div id="method-M000038" class="method-detail"> <a name="M000038"></a> <div class="method-heading"> <a href="Rio.src/M000038.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000038.html');return false;"> <span class="method-name">read</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> For directories proxies Dir#read, otherwise proxies IO#read </p> <p> Proxy for IO#read </p> <pre> ario.read([integer [, buffer]]) => string, buffer, or nil </pre> <p> Reads at most <em>integer</em> bytes from the I/O stream, or to the end of file if <em>integer</em> is omitted or is <tt>nil</tt>. If the optional <em>buffer</em> argument is present, it must reference a String, which will receive the data. Returns <tt>nil</tt> if called at end of file. </p> <pre> f = rio("testfile") f.read(16) #=> "This is line one" rio("testfile").read(16) #=> "This is line one" </pre> <p> Proxy for Dir#read </p> <pre> dir.read => ario or nil </pre> </div> </div> <div id="method-M000168" class="method-detail"> <a name="M000168"></a> <div class="method-heading"> <a href="Rio.src/M000168.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000168.html');return false;"> <span class="method-name">readable?</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> Calls FileTest#readable? </p> <pre> rio('afile').readable? => true or false </pre> <p> Returns <tt>true</tt> if the named file is readable by the effective user </p> <pre> id of this process. </pre> </div> </div> <div id="method-M000169" class="method-detail"> <a name="M000169"></a> <div class="method-heading"> <a href="Rio.src/M000169.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000169.html');return false;"> <span class="method-name">readable_real?</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> Calls FileTest#readable_real? </p> <pre> rio('afile').readable_real? => true or false </pre> <p> Returns <tt>true</tt> if the named file is readable by the real user id of this process. </p> </div> </div> <div id="method-M000125" class="method-detail"> <a name="M000125"></a> <div class="method-heading"> <a href="Rio.src/M000125.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000125.html');return false;"> <span class="method-name">readline</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> Calls IO#readline </p> <pre> ario.readline(sep_string=$/) => string </pre> <p> Reads a line as with +IO#gets+, but raises an <tt>EOFError</tt> on end of file. </p> </div> </div> <div id="method-M000124" class="method-detail"> <a name="M000124"></a> <div class="method-heading"> <a href="Rio.src/M000124.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000124.html');return false;"> <span class="method-name">readlines</span><span class="method-args">(*args,&block)</span> </a> </div> <div class="method-description"> <p> Calls IO#readlines </p> <p> Reads all of the lines in a <a href="Rio.html">Rio</a>, and returns them in anArray. Lines are separated by the optional aSepString. The stream must be opened for reading or an IOerror will be raised. </p> <pre> an_array = rio('afile.txt').readlines # read afile.txt into an array an_array = rio('afile.txt').chomp.readlines # read afile.txt into an array with each line chomped </pre> </div> </div> <div id="method-M000036" class="method-detail"> <a name="M000036"></a> <div class="method-heading"> <a href="Rio.src/M000036.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000036.html');return false;"> <span class="method-name">readlink</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> Calls File#readlink </p> <p> Returns a <a href="Rio.html">Rio</a> referencing the file referenced by the given link. Not available on all platforms. </p> </div> </div> <div id="method-M000119" class="method-detail"> <a name="M000119"></a> <div class="method-heading"> <a href="Rio.src/M000119.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000119.html');return false;"> <span class="method-name">recno</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Returns the current record number of a <a href="Rio.html">Rio</a>. The <tt>recno</tt> is the index used by the grande selection methods. It represents the zero-based index of the last record read. Returns nil until a record has been read. </p> <p> see <a href="Rio.html#M000055">Rio#lines</a> <a href="Rio.html#M000056">Rio#bytes</a> and <a href="Rio.html#M000057">Rio#records</a> </p> <p> To illustrate: Given a file containing three lines "L0\n","L1\n","L2\n" and a Range (0..1) Each of the following would fill ay with ["L0\n", "L1\n"] </p> <pre> ay = [] range = (0..1) ain = rio('afile').readlines ain.each_with_index do |line,i| ay << line if range === i end ay = rio('afile').lines[0..1] </pre> <p> <tt>recno</tt> counts the number of times <a href="Rio.html#M000052">Rio#getrec</a> or <a href="Rio.html#M000045">Rio#each</a> is used to get a record. so <tt>recno</tt> will only concern parts of the file read with grande methods <a href="Rio.html#M000045">Rio#each</a>, <a href="Rio.html">Rio</a>#[], <a href="Rio.html#M000052">Rio#getrec</a> </p> <p> See also <a href="Rio.html#M000117">Rio#lineno</a> </p> <pre> f = rio("afile") r1 = (0..1) r2 = (100..101) aout1 = [] f.each { |rec| aout << rec if r1 === f.recno or r2 === f.recno } aout2 = f[r1,r2] aout1 == aout2 # true </pre> </div> </div> <div id="method-M000057" class="method-detail"> <a name="M000057"></a> <div class="method-heading"> <a href="Rio.src/M000057.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000057.html');return false;"> <span class="method-name">records</span><span class="method-args">(*args,&block)</span> </a> </div> <div class="method-description"> <p> Specifies which records will be iterated through by <a href="Rio.html#M000045">Rio#each</a> or returned by <a href="Rio.html#M000052">Rio#getrec</a> </p> <p> If called with a block behaves as if <tt>records(*args).each(&block)</tt> had been called </p> <p> Returns the <a href="Rio.html">Rio</a> </p> <p> If no args are provided, all records are selected. What constitutes a record is affected by <a href="Rio.html#M000055">Rio#lines</a>,<a href="Rio.html#M000056">Rio#bytes</a>, and extensions such as Rio#csv. </p> <p> If args are provided they may be one or more of the following: </p> <dl> <dt>Regexp</dt><dd>any matching record will be iterated over by <a href="Rio.html#M000045">Rio#each</a> or returned by <a href="Rio.html#M000052">Rio#getrec</a> </dd> <dt>Integer</dt><dd>specifies a record-number (zero-based) to be iterated over by <a href="Rio.html#M000045">Rio#each</a> or returned by <a href="Rio.html#M000052">Rio#getrec</a> </dd> <dt>Range</dt><dd>specifies a range of records (zero-based) to included in the iteration </dd> <dt>Proc</dt><dd>a proc which will be called for each record, records are included unless nil or false is returned </dd> <dt>Symbol</dt><dd>a symbol which will <em>sent</em> to each record, records are included unless nil or false is returned </dd> </dl> <p> Note in the following examples that since <tt>lines</tt> is the default <tt>ario.records(*args)</tt> is effectively the same as <tt>ario.lines(*args)</tt>. </p> <pre> rio('afile').records(0) { |line| ... } # iterate over the first line of 'afile' rio('afile').records(0,5..7)) { |line| ... } # iterate over lines 0,5,6 and 7 rio('afile').records(/Zippy/) { |line| ... } # iterate over all lines containing 'Zippy' rio('afile').lines(0,/^\s*#/) { |line| ... } # iterate over the first line and comment lines rio('afile').records(0,/^\s*#/) { |line| ... } # same thing rio('afile').lines(proc { |rec,rnum,rio| rnum == 0 || rec =~ /^\s*#/ }) { |line| ... } # same thing rio('afile').chomp.lines(proc { |rec,rnum,rio| rec.size > 0 }) { |line| ... } # non-empty lines # return array containing line 0, all comment lines and any line containing the filename of the Rio rio('afile').lines[0,/^\s*#/,proc { |rec,rnum,ario| rec =~ /#{ario.filename}/ }] </pre> </div> </div> <div id="method-M000025" class="method-detail"> <a name="M000025"></a> <div class="method-heading"> <a href="Rio.src/M000025.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000025.html');return false;"> <span class="method-name">recurse</span><span class="method-args">(*args,&block)</span> </a> </div> <div class="method-description"> <p> Grande Directory Recursion Selection Method </p> <p> Sets the <a href="Rio.html">Rio</a> to recurse into directories like <a href="Rio.html#M000024">Rio#all</a>. If no args are provided behaves like <a href="Rio.html#M000024">Rio#all</a>. If args are provided, they are processed like <a href="Rio.html#M000018">Rio#dirs</a>, to select which subdirectories should be recursed into. <a href="Rio.html#M000025">Rio#recurse</a> always implies <a href="Rio.html#M000024">Rio#all</a>. </p> <p> <tt>args</tt> may be one or more of: </p> <table> <tr><td valign="top">Regexp:</td><td>recurse into matching subdirectories </td></tr> <tr><td valign="top">glob:</td><td>recurse into matching subdirectories </td></tr> <tr><td valign="top">Proc:</td><td>called for each directory. The directory is recursed into unless the proc returns false </td></tr> <tr><td valign="top">Symbol:</td><td>sent to each directory. Each directory is recursed into unless the symbol returns false </td></tr> </table> <p> If a block is given, behaves like <tt>ario.recurse(*args).each(&block)</tt> </p> <p> See also <a href="Rio.html#M000026">Rio#norecurse</a>, <a href="Rio.html#M000024">Rio#all</a>, <a href="Rio.html#M000018">Rio#dirs</a> </p> <pre> rio('adir').all.recurse('test*') { |drio| ... } # process all entries and all entries in subdirectories # starting with 'test' -- recursively </pre> </div> </div> <div id="method-M000087" class="method-detail"> <a name="M000087"></a> <div class="method-heading"> <a href="Rio.src/M000087.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000087.html');return false;"> <span class="method-name">rel</span><span class="method-args">(other)</span> </a> </div> <div class="method-description"> <p> Returns a new rio with a path equal to the relative path from <em>other</em> </p> <pre> rio('/tmp/afile').rel('/tmp') #=> rio('afile') rio('zippy/afile').rel('zippy') #=> rio('afile') </pre> </div> </div> <div id="method-M000037" class="method-detail"> <a name="M000037"></a> <div class="method-heading"> <a href="Rio.src/M000037.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000037.html');return false;"> <span class="method-name">rename</span><span class="method-args">(*args,&block)</span> </a> </div> <div class="method-description"> <p> If called with an argument calls FileUtils#rename If called without an argument puts the <a href="Rio.html">Rio</a> in a rename mode in which changes to the <a href="Rio.html">Rio</a>’s path affect a rename of the file on the file system. </p> <p> Proxy for FileUtils#rename </p> <pre> ario = rio('afile.cpp') ario.rename('afile.cxx') # renamed the file, but ario still references # the old path </pre> <p> Rename Mode </p> <p> Change the extension of all’.cpp’ files in ‘adir’ to ’.cxx’ </p> <pre> rio('adir').rename.files('*.cpp') do |file| file.ext = '.cxx' # 'file' references the new path and the actual file is renamed end </pre> <p> Recursively change all ’.tar.gz’ files to ’.tgz’ files </p> <pre> rio('adir').rename.all.files('*.tar.gz') do |gzfile| gzfile.ext('.tar.gz').ext = '.tgz' end </pre> <p> See <a href="Rio.html#M000093">Rio#dirname</a>=, <a href="Rio.html#M000095">Rio#filename</a>=, <a href="Rio.html#M000092">Rio#basename</a>=, and <a href="Rio.html#M000094">Rio#extname</a>= </p> </div> </div> <div id="method-M000053" class="method-detail"> <a name="M000053"></a> <div class="method-heading"> <a href="Rio.src/M000053.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000053.html');return false;"> <span class="method-name">reset</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> This is an internal function and should not normally be needed in client code. It closes a <a href="Rio.html">Rio</a> and returns it to its ‘reset’ state. </p> </div> </div> <div id="method-M000039" class="method-detail"> <a name="M000039"></a> <div class="method-heading"> <a href="Rio.src/M000039.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000039.html');return false;"> <span class="method-name">rewind</span><span class="method-args">(&block)</span> </a> </div> <div class="method-description"> <p> For directories proxies Dir#rewind, otherwise proxies IO#rewind </p> <p> Proxy for IO#rewind </p> <pre> ario.rewind => ario </pre> <p> Positions <em>ario</em> to the beginning of input, resetting lineno to zero. </p> <p> Returns the <a href="Rio.html">Rio</a> </p> <pre> f = rio("testfile") f.readline #=> "This is line one\n" f.rewind #=> f f.lineno #=> 0 f.readline #=> "This is line one\n" f.rewind.readline #=> "This is line one\n" </pre> <p> Proxy for Dir#rewind </p> <pre> ario.rewind => ario </pre> </div> </div> <div id="method-M000054" class="method-detail"> <a name="M000054"></a> <div class="method-heading"> <a href="Rio.src/M000054.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000054.html');return false;"> <span class="method-name">rl</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> This is an internal function and is not needed in client code. It returns the internal ‘<a href="Rio.html">Rio</a> Resource Locator’ object. </p> </div> </div> <div id="method-M000033" class="method-detail"> <a name="M000033"></a> <div class="method-heading"> <a href="Rio.src/M000033.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000033.html');return false;"> <span class="method-name">rm</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Calls FileUtils#rm </p> <p> Deletes the referenced file, returning the <a href="Rio.html">Rio</a>. Raises an exception on any error. </p> <p> See also <a href="Rio.html#M000046">Rio#delete</a>, <a href="Rio.html#M000046">Rio#delete</a>!, <a href="Rio.html#M000029">Rio#rmdir</a>. </p> </div> </div> <div id="method-M000029" class="method-detail"> <a name="M000029"></a> <div class="method-heading"> <a href="Rio.src/M000029.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000029.html');return false;"> <span class="method-name">rmdir</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Calls Dir#rmdir </p> <p> Deletes the directory referenced by the <a href="Rio.html">Rio</a>. Raises a subclass of SystemCallError if the directory isn�t empty. Returns the <a href="Rio.html">Rio</a>. If the directory does not exist, just returns the <a href="Rio.html">Rio</a>. </p> <p> See also <a href="Rio.html#M000030">Rio#rmtree</a>, <a href="Rio.html#M000046">Rio#delete</a>, <a href="Rio.html#M000046">Rio#delete</a>! </p> <pre> rio('adir').rmdir # remove the empty directory 'adir' </pre> </div> </div> <div id="method-M000030" class="method-detail"> <a name="M000030"></a> <div class="method-heading"> <a href="Rio.src/M000030.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000030.html');return false;"> <span class="method-name">rmtree</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Calls FileUtils#rmtree </p> <p> Removes a directory <a href="Rio.html">Rio</a> recursively. Returns the <a href="Rio.html">Rio</a>. If the directory does not exist, simply returns the <a href="Rio.html">Rio</a> </p> <p> If called with a block, behaves as if rmtree.each(&block) had been called </p> <p> See also <a href="Rio.html#M000046">Rio#delete</a>! </p> <pre> rio('adir').rmtree # removes the directory 'adir' recursively # delete the directory 'adir', recreate it and then change to the new directory rio('adir/asubdir').rmtree.mkpath.chdir { ... } </pre> </div> </div> <div id="method-M000107" class="method-detail"> <a name="M000107"></a> <div class="method-heading"> <a href="Rio.src/M000107.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000107.html');return false;"> <span class="method-name">rootpath</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> <a href="Rio.html#M000107">Rio#rootpath</a> </p> </div> </div> <div id="method-M000112" class="method-detail"> <a name="M000112"></a> <div class="method-heading"> <a href="Rio.src/M000112.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000112.html');return false;"> <span class="method-name">route_from</span><span class="method-args">(other)</span> </a> </div> <div class="method-description"> <p> Calls URI#route_from </p> <p> Returns a new rio representing the path to this <a href="Rio.html">Rio</a> from the perspective of <em>other</em>. URI#route_from requires that absolute URIs be used. <a href="Rio.html#M000112">Rio#route_from</a> does not. </p> </div> </div> <div id="method-M000113" class="method-detail"> <a name="M000113"></a> <div class="method-heading"> <a href="Rio.src/M000113.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000113.html');return false;"> <span class="method-name">route_to</span><span class="method-args">(other)</span> </a> </div> <div class="method-description"> <p> Calls URI#route_to </p> <p> Returns a new rio representing the path to <em>other</em> from the perspective of this <a href="Rio.html">Rio</a>. URI#route_to requires that absolute URIs be used. <a href="Rio.html#M000113">Rio#route_to</a> does not. </p> </div> </div> <div id="method-M000060" class="method-detail"> <a name="M000060"></a> <div class="method-heading"> <a href="Rio.src/M000060.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000060.html');return false;"> <span class="method-name">rows</span><span class="method-args">(*args,&block)</span> </a> </div> <div class="method-description"> <p> Sets the <a href="Rio.html">Rio</a> to read rows and specifies rows which should be iterated through by <a href="Rio.html#M000045">Rio#each</a> or returned by <a href="Rio.html#M000052">Rio#getrec</a> <a href="Rio.html#M000060">Rio#rows</a> is intended for use by extensions, where the concept of a row is reasonable. In the absensence of an extension behaves like <a href="Rio.html#M000057">Rio#records</a> </p> </div> </div> <div id="method-M000108" class="method-detail"> <a name="M000108"></a> <div class="method-heading"> <a href="Rio.src/M000108.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000108.html');return false;"> <span class="method-name">scheme</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> Returns the scheme for the <a href="Rio.html">Rio</a>’s URI like URI#scheme where the <a href="Rio.html">Rio</a> is represented by a standard URI. For Rios that are not represented by standard URIs one of <a href="Rio.html">Rio</a>’s non-standard schemes is returned. </p> <pre> rio('http://ruby-doc.org/').scheme #=> 'http' </pre> </div> </div> <div id="method-M000040" class="method-detail"> <a name="M000040"></a> <div class="method-heading"> <a href="Rio.src/M000040.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000040.html');return false;"> <span class="method-name">seek</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> For directories proxies Dir#seek, otherwise proxies IO#seek </p> <p> Proxy for IO#seek </p> <pre> ario.seek(amount, whence=SEEK_SET) -> ario </pre> <p> Seeks to a given offset <em>amount</em> in the stream according to the value of <em>whence</em>: </p> <pre> IO::SEEK_CUR | Seeks to <em>amount</em> plus current position --------------+---------------------------------------------------- IO::SEEK_END | Seeks to <em>amount</em> plus end of stream (you probably | want a negative value for <em>amount</em>) --------------+---------------------------------------------------- IO::SEEK_SET | Seeks to the absolute location given by <em>amount</em> </pre> <p> Example: </p> <pre> f = rio("testfile") f.seek(-28, IO::SEEK_END).readline #=> "happily ever after. The End\n" </pre> <p> Proxy for Dir#seek </p> <pre> ario.seek( integer ) => ario </pre> <p> Seeks to a particular location in <em>ario</em>. <em>integer</em> must be a value returned by +Dir#tell+ or <a href="Rio.html#M000042">Rio#tell</a>. </p> <pre> d = rio("testdir") #=> #<RIO::Rio:0x401b3c40> d.read #=> rio(".") i = d.tell #=> 12 d.read #=> rio("..") d.seek(i) #=> #<RIO::Rio:0x401b3c40> d.read #=> rio("..") </pre> </div> </div> <div id="method-M000175" class="method-detail"> <a name="M000175"></a> <div class="method-heading"> <a href="Rio.src/M000175.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000175.html');return false;"> <span class="method-name">setgid?</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> Calls FileTest#setgid? </p> <pre> rio('afile').setgid? => true or false </pre> <p> Returns <tt>true</tt> if the named file is a has the setgid bit set. </p> </div> </div> <div id="method-M000176" class="method-detail"> <a name="M000176"></a> <div class="method-heading"> <a href="Rio.src/M000176.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000176.html');return false;"> <span class="method-name">setuid?</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> Calls FileTest#setuid? </p> <pre> rio('afile').setuid? => true or false </pre> <p> Returns <tt>true</tt> if the named file is a has the setuid bit set. </p> </div> </div> <div id="method-M000177" class="method-detail"> <a name="M000177"></a> <div class="method-heading"> <a href="Rio.src/M000177.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000177.html');return false;"> <span class="method-name">size</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> Calls FileTest#size </p> <pre> rio('afile').size => integer </pre> <p> Returns the size of <em>afile</em>. To get the length of the <a href="Rio.html">Rio</a>’s string representation use <a href="Rio.html#M000011">Rio#length</a> </p> </div> </div> <div id="method-M000178" class="method-detail"> <a name="M000178"></a> <div class="method-heading"> <a href="Rio.src/M000178.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000178.html');return false;"> <span class="method-name">size?</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> Calls FileTest#size? </p> <pre> rio('afile').size? => integer or nil </pre> <p> Returns <tt>nil</tt> if <em>afile</em> doesn’t exist or has zero size, the size of the file otherwise. </p> </div> </div> <div id="method-M000115" class="method-detail"> <a name="M000115"></a> <div class="method-heading"> <a href="Rio.src/M000115.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000115.html');return false;"> <span class="method-name">slurp</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Slurps the contents of the rio into a string. See also <a href="Rio.html#M000116">Rio#contents</a> </p> <pre> astring = rio('afile.txt').slurp # slurp the entire contents of afile.txt into astring </pre> <p> Alpha Note: Considering removing <a href="Rio.html#M000116">Rio#contents</a> and <a href="Rio.html#M000115">Rio#slurp</a> in favor of <tt>to_string</tt>. Is this the Ruby way? Is it too confusing with a <tt><a href="Rio.html#M000008">to_s</a></tt> and <tt>to_str</tt> already? Is it a good idea? </p> </div> </div> <div id="method-M000154" class="method-detail"> <a name="M000154"></a> <div class="method-heading"> <a href="Rio.src/M000154.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000154.html');return false;"> <span class="method-name">socket?</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Calls FileTest#socket? </p> <pre> rio('afile').socket? => true or false </pre> <p> Returns <tt>true</tt> if the named file is a socket. </p> </div> </div> <div id="method-M000101" class="method-detail"> <a name="M000101"></a> <div class="method-heading"> <a href="Rio.src/M000101.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000101.html');return false;"> <span class="method-name">split</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Creates an array of Rios, one for each path element. (Note that this behavior differs from File#split.) </p> <pre> rio('a/b/c').split #=> [rio('a'),rio('b'),rio('c')] </pre> <p> The array returned is extended with a <tt>to_rio</tt> method, which will put the parts back together again. </p> <pre> ary = rio('a/b/c').split #=> [rio('a'),rio('b'),rio('c')] ary.to_rio #=> rio('a/b/c') ary = rio('a/b/c').split #=> [rio('a'),rio('b'),rio('c')] ary[1] = rio('d') ary.to_rio #=> rio('a/d/c') </pre> <p> See also <a href="Rio.html#M000100">Rio#join</a>, <a href="Rio.html">Rio</a>#/ </p> </div> </div> <div id="method-M000160" class="method-detail"> <a name="M000160"></a> <div class="method-heading"> <a href="Rio.src/M000160.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000160.html');return false;"> <span class="method-name">stat</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> Calls File#stat </p> </div> </div> <div id="method-M000172" class="method-detail"> <a name="M000172"></a> <div class="method-heading"> <a href="Rio.src/M000172.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000172.html');return false;"> <span class="method-name">sticky?</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> Calls FileTest#sticky? </p> <pre> rio('afile').sticky? => true or false </pre> <p> Returns <tt>true</tt> if the named file is a has the sticky bit set. </p> </div> </div> <div id="method-M000104" class="method-detail"> <a name="M000104"></a> <div class="method-heading"> <a href="Rio.src/M000104.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000104.html');return false;"> <span class="method-name">sub</span><span class="method-args">(re,string)</span> </a> </div> <div class="method-description"> <p> Create a new <a href="Rio.html">Rio</a> referencing the result of applying String#sub to the value returned by <a href="Rio.html#M000008">Rio#to_s</a>. So: </p> <pre> ario.sub(re,string) </pre> <p> is equivelent to </p> <pre> rio(ario.to_s.sub(re,string)) </pre> </div> </div> <div id="method-M000035" class="method-detail"> <a name="M000035"></a> <div class="method-heading"> <a href="Rio.src/M000035.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000035.html');return false;"> <span class="method-name">symlink</span><span class="method-args">(dest)</span> </a> </div> <div class="method-description"> <p> Creates a symbolic link <em>dest</em> which points to the <a href="Rio.html">Rio</a>’s <a href="Rio.html#M000084">Rio#fspath</a>. Raises a NotImplementedError exception on platforms that do not support symbolic links. <em>dest</em> may be a <a href="Rio.html">Rio</a>, a String, or anything that will create an appropriate <a href="Rio.html">Rio</a> when passed to <a href="Rio.html#M000004">Rio#new</a> If <em>dest</em> already exists and is a directory, creates a symbolic link in the <em>dest</em> directory, named with the name returned by <a href="Rio.html#M000095">Rio#filename</a> If <em>dest</em> already exists and it is not a directory, raises Errno::EEXIST. </p> <p> Returns the <a href="Rio.html">Rio</a> (not the symlink) </p> <p> <a href="Rio.html#M000035">Rio#symlink</a> differs from File#symlink when the <a href="Rio.html">Rio</a> or the <em>dest</em> path has directory information. In this case <a href="Rio.html#M000035">Rio#symlink</a> creates a symlink that actually refers to the <a href="Rio.html">Rio</a>’s location from the perspective of the link’s location. </p> <p> For example: Given an existing file ‘adir/afile’ and a <em>dest</em> of ‘adir/alink‘ </p> <pre> ::File.symlink('adir/afile','adir/alink1') # creates 'adir/alink1 -> adir/afile' ::File.exist?('adir/alink1') # false rio('adir/afile').symlink('adir/alink2') # creates 'adir/alink2 -> afile' ::File.exist?('adir/alink2') # true </pre> <p> To replace an existing symlink use the following <a href="Rio.html">Rio</a> idiom </p> <pre> rio('afile').symlink( rio('link_name').delete ) # delete 'link_name' and recreate linked to 'afile' </pre> <p> Examples </p> <pre> rio('afile').symlink('alink') # create the symbolic link 'alink' which references 'afile' rio('afile').symlink('adir/alink') # create a symlink 'adir/alink' -> '../afile' rio('adir/afile').symlink('alink') # create a symlink 'alink' -> 'adir/afile' rio('adir/afile').symlink('adir/alink') # create a symlink 'adir/alink' -> 'afile' rio('adir/afile').symlink('adir/alink') # create a symlink 'adir/alink' -> 'afile' rio('adir1/afile').symlink('adir2/alink') # create a symlink 'adir2/alink' -> '../adir1/afile' rio('/tmp/afile').symlink('alink') # create a symlink 'adir/alink' -> '/tmp/afile' </pre> </div> </div> <div id="method-M000155" class="method-detail"> <a name="M000155"></a> <div class="method-heading"> <a href="Rio.src/M000155.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000155.html');return false;"> <span class="method-name">symlink?</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Calls FileTest#symlink? </p> <pre> rio('afile').symlink? => true or false </pre> <p> Returns <tt>true</tt> if the named file is a symbolic link. </p> </div> </div> <div id="method-M000078" class="method-detail"> <a name="M000078"></a> <div class="method-heading"> <a href="Rio.src/M000078.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000078.html');return false;"> <span class="method-name">sync</span><span class="method-args">(arg=true,&block)</span> </a> </div> <div class="method-description"> <p> Sets the ‘sync-mode’ of the underlying IO using IO#sync= </p> <pre> ario.sync(boolean=true,&block) => ario </pre> <p> Sets the <a href="Rio.html">Rio</a> so that its ‘sync mode’ will be set to <tt>true</tt> or <tt>false</tt> when opened, or set it immediatly if already open. When sync mode is true, all output is immediately flushed to the underlying operating system and is not buffered internally. Returns the rio. See also <a href="Rio.html#M000145">Rio#fsync</a>, <a href="Rio.html#M000079">Rio#nosync</a>, <a href="Rio.html#M000078">Rio#sync</a>?. </p> <p> If a block is given behaves like <tt>ario.sync(arg).each(&block)</tt> </p> <pre> f = rio("testfile").sync.puts("Hello World") f.sync? # => true </pre> </div> </div> <div id="method-M000080" class="method-detail"> <a name="M000080"></a> <div class="method-heading"> <a href="Rio.src/M000080.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000080.html');return false;"> <span class="method-name">sync?</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Query the current ‘sync mode’ with IO#sync </p> <pre> ario.sync? => true or false </pre> <p> Returns the current ``sync mode’’ of <em>ario</em>. When sync mode is true, all output is immediately flushed to the underlying operating system and is not buffered by Ruby internally. See also +<a href="Rio.html#M000145">Rio#fsync</a>+, <a href="Rio.html#M000078">Rio#sync</a>, <a href="Rio.html#M000079">Rio#nosync</a> </p> <pre> f = rio("testfile") f.sync? #=> false </pre> </div> </div> <div id="method-M000042" class="method-detail"> <a name="M000042"></a> <div class="method-heading"> <a href="Rio.src/M000042.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000042.html');return false;"> <span class="method-name">tell</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> See <a href="Rio.html#M000041">Rio#pos</a> </p> </div> </div> <div id="method-M000008" class="method-detail"> <a name="M000008"></a> <div class="method-heading"> <a href="Rio.src/M000008.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000008.html');return false;"> <span class="method-name">to_s</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> returns the <a href="Rio.html#M000084">Rio#fspath</a>, which is the path for the <a href="Rio.html">Rio</a> on the underlying filesystem </p> </div> </div> <div id="method-M000083" class="method-detail"> <a name="M000083"></a> <div class="method-heading"> <a href="Rio.src/M000083.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000083.html');return false;"> <span class="method-name">to_uri</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> For resources that have a URL (RFC1738) representation, this returns a URI object referencing it. Otherwise this raises NoMethodError. </p> <pre> rio('http://rubyforge.org/').to_uri #=> <URI::HTTP:0x818bd84 URL:http://rubyforge.org/> rio('adir/afile').to_uri #=> <URI::Generic:0x817d288 URL:adir/afile> </pre> </div> </div> <div id="method-M000082" class="method-detail"> <a name="M000082"></a> <div class="method-heading"> <a href="Rio.src/M000082.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000082.html');return false;"> <span class="method-name">to_url</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> For resources that have a absolute URL (RFC1738) representation, this returns a string containing that representation. For objects that do not this returns a RIORL (a descriptive pseudo-URL). </p> <pre> rio('/var/www/') #=> "file:///var/www/" rio('http://rio.rubyforge.org/') #=> "http://rio.rubyforge.org" </pre> </div> </div> <div id="method-M000034" class="method-detail"> <a name="M000034"></a> <div class="method-heading"> <a href="Rio.src/M000034.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000034.html');return false;"> <span class="method-name">touch</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Calls FileUtils#touch </p> <p> Updates modification time (mtime) and access time (atime) of a <a href="Rio.html">Rio</a>. A file is created if it doesn’t exist. </p> </div> </div> <div id="method-M000146" class="method-detail"> <a name="M000146"></a> <div class="method-heading"> <a href="Rio.src/M000146.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000146.html');return false;"> <span class="method-name">tty?</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Calls IO#tty? </p> <pre> ario.tty? => true or false </pre> <p> Returns <tt>true</tt> if <em>ario</em> is associated with a terminal device (tty), <tt>false</tt> otherwise. </p> <pre> rio("testfile").tty? #=> false rio("/dev/tty").tty? #=> true </pre> </div> </div> <div id="method-M000147" class="method-detail"> <a name="M000147"></a> <div class="method-heading"> <a href="Rio.src/M000147.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000147.html');return false;"> <span class="method-name">ungetc</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> Calls IO#ungetc </p> <pre> ario.ungetc(integer) => ario </pre> <p> Pushes back one character (passed as a parameter) onto <em>ario</em>, such that a subsequent buffered read will return it. Only one character may be pushed back before a subsequent read operation (that is, you will be able to read only the last of several characters that have been pushed back). </p> <pre> f = rio("testfile") #=> #<Rio:testfile> c = f.getc #=> 84 f.ungetc(c).getc #=> 84 </pre> </div> </div> <div id="method-M000066" class="method-detail"> <a name="M000066"></a> <div class="method-heading"> <a href="Rio.src/M000066.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000066.html');return false;"> <span class="method-name">w</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Sets the implicit output mode to ‘w’. </p> <p> The implicit output mode is the mode <a href="Rio.html">Rio</a> will use for output when no mode is specified. </p> <p> Returns the <a href="Rio.html">Rio</a> </p> <p> See the discussion for <a href="Rio.html#M000062">Rio#a</a>. </p> <p> Since ‘w’ is the implicit output mode used by default, this method is uneeded, is considered experimental and may be removed at any time. </p> </div> </div> <div id="method-M000067" class="method-detail"> <a name="M000067"></a> <div class="method-heading"> <a href="Rio.src/M000067.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000067.html');return false;"> <span class="method-name">w!</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Sets the implicit output mode to ‘w+’. </p> <p> The implicit output mode is the mode <a href="Rio.html">Rio</a> will use for output when no mode is specified. </p> <p> Returns the <a href="Rio.html">Rio</a> </p> <p> See the discussion for <a href="Rio.html#M000062">Rio#a</a>. </p> </div> </div> <div id="method-M000170" class="method-detail"> <a name="M000170"></a> <div class="method-heading"> <a href="Rio.src/M000170.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000170.html');return false;"> <span class="method-name">writable?</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> Calls FileTest#writable? </p> <pre> rio('afile').writable? => true or false </pre> <p> Returns <tt>true</tt> if the named file is writable by the effective user id of this process. </p> </div> </div> <div id="method-M000171" class="method-detail"> <a name="M000171"></a> <div class="method-heading"> <a href="Rio.src/M000171.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000171.html');return false;"> <span class="method-name">writable_real?</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> Calls FileTest#writable_real? </p> <pre> rio('afile').writable_real? => true or false </pre> <p> Returns <tt>true</tt> if the named file is writable by the real user id of this process. </p> </div> </div> <div id="method-M000135" class="method-detail"> <a name="M000135"></a> <div class="method-heading"> <a href="Rio.src/M000135.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000135.html');return false;"> <span class="method-name">write</span><span class="method-args">(*argv)</span> </a> </div> <div class="method-description"> <p> Calls IO#write </p> <pre> ario.write(string) => integer </pre> <p> Writes the given string to <em>ario</em>. If the argument is not a string, it will be converted to a string using <tt><a href="Rio.html#M000008">to_s</a></tt>. Returns the number of bytes written. </p> </div> </div> <div id="method-M000134" class="method-detail"> <a name="M000134"></a> <div class="method-heading"> <a href="Rio.src/M000134.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000134.html');return false;"> <span class="method-name">write!</span><span class="method-args">(*argv)</span> </a> </div> <div class="method-description"> <p> Writes the given objects to the rio as with <a href="Rio.html#M000135">Rio#write</a> and then closes the rio. </p> <p> Equivalent to </p> <pre> ario.write(*args) ario.close </pre> </div> </div> <div id="method-M000179" class="method-detail"> <a name="M000179"></a> <div class="method-heading"> <a href="Rio.src/M000179.html" target="Code" class="method-signature" onclick="popupCode('Rio.src/M000179.html');return false;"> <span class="method-name">zero?</span><span class="method-args">(*args)</span> </a> </div> <div class="method-description"> <p> Calls FileTest#zero? </p> <pre> rio('afile').zero? => true or false </pre> <p> Returns <tt>true</tt> if the named file exists and has a zero size. </p> </div> </div> </div> </div> <div id="validator-badges"> <p><small>Copyright © 2005 Christopher Kleckner. <a href="http://www.gnu.org/licenses/gpl.html">All rights reserved</a>.</small></p> </div> </body> </html>