Module RIO lib/rio.rb    lib/rio/doc/HOWTO.rb    lib/rio/doc/INTRO.rb    lib/rio/doc/MISC.rb    lib/rio/doc/SYNOPSIS.rb    lib/rio/if/basic.rb    lib/rio/if/dir.rb    lib/rio/if/file.rb    lib/rio/if/fileordir.rb    lib/rio/if/grande.rb    lib/rio/if/internal.rb    lib/rio/if/methods.rb    lib/rio/if/path.rb    lib/rio/if/stream.rb    lib/rio/if/test.rb    lib/rio/constructor.rb   

To create the documentation for Rio run the command

 rake rdoc

from the distribution directory. Then point your browser at the ‘doc/rdoc’ directory.

Suggested Reading

Rio is pre-alpha software. The documented interface and behavior is subject to change without notice.

Methods

cwd   rio   root  

Classes and Modules

Module RIO::Doc
Class RIO::Rio

Constants

SEEK_SET = IO::SEEK_SET
SEEK_END = IO::SEEK_END
SEEK_CUR = IO::SEEK_CUR

Public Instance methods

Create a Rio as with RIO#rio which refers to the current working directory

 wd = RIO.cwd

Rio Constructor

For purposes of discussion, we divide Rios into two catagories, those that have a path and those that don’t.

Creating a Rio that has a path

To create a Rio that has a path the arguments to rio may be:

  • a string representing the entire path. The separator used for Rios is as specified in RFC1738 (’/’).
     rio('adir/afile')
    
  • a string representing a fully qualified file URL as per RFC1738
     rio('file:///atopleveldir/adir/afile')
    
  • a URI object representing a file or generic URL
     rio(URI('adir/afile'))
    
  • the components of a path as separate arguments
     rio('adir','afile')
    
  • the components of a path as an array of separate arguments
     rio(%w/adir afile/)
    
  • another Rio
     another_rio = rio('adir/afile')
     rio(another_rio)
    
  • any object whose to_s method returns one of the above
     rio(Pathname.new('apath'))
    
  • any combination of the above either as separate arguments or as elements of an array,
     another_rio = rio('dir1/dir2')
     auri = URI('dir4/dir5)
     rio(another_rio,'dir3',auri,'dir6/dir7')
    
Creating a Rio that refers to a web page

To create a Rio that refers to a web page the arguments to rio may be:

  • a string representing a fully qualified http URL
     rio('http://ruby-doc.org/index.html')
    
  • a URI object representing a http URL
     rio(URI('http://ruby-doc.org/index.html'))
    
  • either of the above with additional path elements
     rio('http://www.ruby-doc.org/','core','classes/Object.html')
    
Creating a Rio that refers to a file or directory on a FTP server

To create a Rio that refers to a file on a FTP server the arguments to rio may be:

  • a string representing a fully qualified ftp URL
     rio('ftp://user:password@ftp.example.com/afile.tar.gz')
    
  • a URI object representing a ftp URL
     rio(URI('ftp://ftp.example.com/afile.tar.gz'))
    
  • either of the above with additional path elements
     rio('ftp://ftp.gnu.org/pub/gnu','emacs','windows','README')
    

Creating Rios that do not have a path

To create a Rio without a path, the first argument to rio is usually a single character.

Creating a Rio that refers to a clone of your programs stdin or stdout.

rio(?-) (mnemonic: ’-’ is used by some Unix programs to specify stdin or stdout in place of a file)

Just as a Rio that refers to a file, does not know whether that file will be opened for reading or writing until an I/O operation is specified, a stdio: Rio does not know whether it will connect to stdin or stdout until an I/O operation is specified.

Creating a Rio that refers to a clone of your programs stderr.

rio(?=) (mnemonic: ’-’ refers to fileno 1, so ’=’ refers to fileno 2)

Creating a Rio that refers to an arbitrary IO object.
 an_io = ::File.new('afile')
 rio(an_io)
Creating a Rio that refers to a file descriptor

rio(?#,fd) (mnemonic: a file descriptor is a number ’#’)

 an_io = ::File.new('afile')
 fnum = an_io.fileno
 rio(?#,fnum)
Creating a Rio that refers to a StringIO object

rio(?") (mnemonic: ’"’ surrounds strings)

  • create a Rio that refers to a string that it creates
     rio(?")
    
  • create a Rio that refers to a string of your choosing
     astring = ""
     rio(?",astring)
    
Creating a Rio that refers to a Tempfile object

rio(??) (mnemonic: ’?’ you don’t know its name)

 rio(??)
 rio(??,basename='rio',tmpdir=Dir::tmpdir)

To create a temporary object that will become a file or a directory, depending on how you use it:

 rio(??)
 rio(??,basename='rio',tmpdir=Dir::tmpdir)

To force it to become a file

 rio(??).file

or just write to it.

To force it to become a directory:

 rio(??).dir

or

 rio(??).mkdir

or

 rio(??).chdir
Creating a Rio that refers to an arbitrary TCPSocket
 rio('tcp:',hostname,port)

or

 rio('tcp://hostname:port')
Creating a Rio that runs an external program and connects to its stdin and stdout

rio(?-,cmd) (mnemonic: ’-’ is used by some Unix programs to specify stdin or stdout in place of a file)

or

rio(?`,cmd) (mnemonic: ’`’ (backtick) runs an external program in ruby)

This is Rio’s interface to IO#popen

Create a Rio as with RIO#rio which refers to a directory at the root of the file system

 tmpdir = RIO.root('tmp') #=> rio('/tmp')

Copyright © 2005 Christopher Kleckner. All rights reserved.