To create the documentation for Rio run the command
ruby build_doc.rb
from the distribution directory.
Suggested Reading
Create a Rio as with RIO#rio which refers to the current working directory
wd = RIO.cwd
If passed arguments they are treated as if
rio(RIO.cwd,*args)
had been called
Rio Constructor
For purposes of discussion, we divide Rios into two catagories, those that have a path and those that don’t.
To create a Rio that has a path the arguments to rio may be:
rio('adir/afile')
rio('file:///atopleveldir/adir/afile')
rio(URI('adir/afile'))
rio('adir','afile')
rio(%w/adir afile/)
another_rio = rio('adir/afile') rio(another_rio)
rio(Pathname.new('apath'))
another_rio = rio('dir1/dir2') auri = URI('dir4/dir5) rio(another_rio,'dir3',auri,'dir6/dir7')
To create a Rio that refers to a web page the arguments to rio may be:
rio('http://ruby-doc.org/index.html')
rio(URI('http://ruby-doc.org/index.html'))
rio('http://www.ruby-doc.org/','core','classes/Object.html')
To create a Rio that refers to a file on a FTP server the arguments to rio may be:
rio('ftp://user:password@ftp.example.com/afile.tar.gz')
rio(URI('ftp://ftp.example.com/afile.tar.gz'))
rio('ftp://ftp.gnu.org/pub/gnu','emacs','windows','README')
To create a Rio without a path, the first argument to rio is usually either a single character or a symbol.
rio(?-) (mnemonic: ’-’ is used by some Unix programs to specify stdin or stdout in place of a file)
rio(:stdio)
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.
Currently :stdin and :stdout are allowed as synonyms for :stdio. This allows one to write
rio(:stdout).puts("Hello :stdout")
which is reasonable. It also allows one to write
rio(:stdin).puts("Hello :stdin")
which is not reasonable and will be disallowed in future releases.
rio(?=) (mnemonic: ’-’ refers to fileno 1, so ’=’ refers to fileno 2)
rio(:stderr)
an_io = ::File.new('afile') rio(an_io)
rio(?#,file_descriptor) (mnemonic: a file descriptor is a number ’#’)
rio(:fd,file_descriptor)
an_io = ::File.new('afile') fnum = an_io.fileno rio(?#,fnum)
rio(?") (mnemonic: ’"’ surrounds strings)
rio(:string)
rio(:strio)
rio(:stringio)
rio(?")
astring = "" rio(?",astring)
To create a temporary object that will become a file (Tempfile) or a temporary directory, depending on how it is used.
rio(??) (mnemonic: ’?’ you don’t know its name)
rio(:temp)
The following are also supported, to specify file or directory
rio(:tempfile)
rio(:tempdir)
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(??).mkdir
or
rio(??).chdir
rio(‘tcp:’,hostname,port)
rio(‘tcp://hostname:port’)
rio(:tcp,hostname,port)
rio(?-,cmd) (mnemonic: ’-’ is used by some Unix programs to specify stdin or stdout in place of a file)
rio(?`,cmd) (mnemonic: ’`’ (backtick) runs an external program in ruby)
rio(:cmdio,cmd)
This is Rio’s interface to IO#popen
rio(nil)
rio(:null)
This rio behaves like the Unix file /dev/null, but does depend on it - and thus will work on non-Unix systems. Reading behaves as if reading from an empty file, and writing to it discards anything written.
A Rio Pipe is a sequence of Rios that are run with the output of each being copied to the input of the next.
rio(?|, ario, …) (mnemonic: ’|’ is the Unix pipe operator)
rio(:cmdpipe, ario, …)
See also |
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,2006,2007,2008 Christopher Kleckner. All rights reserved.