--- !ruby/object:RI::ClassDescription attributes: [] class_methods: [] comment: - !ruby/struct:SM::Flow::P body: Class IO is the basis for all input and output in Ruby. An I/O stream may be duplexed (that is, bidirectional), and so may use more than one native operating system stream. - !ruby/struct:SM::Flow::P body: Many of the examples in this section use class File, the only standard subclass of IO. The two classes are closely associated. - !ruby/struct:SM::Flow::P body: As used in this section, portname may take any of the following forms. - !ruby/object:SM::Flow::LIST contents: - !ruby/struct:SM::Flow::LI label: "*" body: A plain string represents a filename suitable for the underlying operating system. - !ruby/struct:SM::Flow::LI label: "*" body: A string starting with ``|'' indicates a subprocess. The remainder of the string following the ``|'' is invoked as a process with appropriate input/output channels connected to it. - !ruby/struct:SM::Flow::LI label: "*" body: A string equal to ``|-'' will create another Ruby instance as a subprocess. type: :BULLET - !ruby/struct:SM::Flow::P body: "Ruby will convert pathnames between different operating system conventions if possible. For instance, on a Windows system the filename ``/gumby/ruby/test.rb'' will be opened as ``\\gumby\\ruby\\test.rb''. When specifying a Windows-style filename in a Ruby string, remember to escape the backslashes:" - !ruby/struct:SM::Flow::VERB body: " "c:\\gumby\\ruby\\test.rb"\n" - !ruby/struct:SM::Flow::P body: Our examples here will use the Unix-style forward slashes; File::SEPARATOR can be used to get the platform-specific separator character. - !ruby/struct:SM::Flow::P body: I/O ports may be opened in any one of several different modes, which are shown in this section as mode. The mode may either be a Fixnum or a String. If numeric, it should be one of the operating system specific constants (O_RDONLY, O_WRONLY, O_RDWR, O_APPEND and so on). See man open(2) for more information. - !ruby/struct:SM::Flow::P body: If the mode is given as a String, it must be one of the values listed in the following table. - !ruby/struct:SM::Flow::VERB body: " Mode | Meaning\n -----+--------------------------------------------------------\n "r" | Read-only, starts at beginning of file (default mode).\n -----+--------------------------------------------------------\n "r+" | Read-write, starts at beginning of file.\n -----+--------------------------------------------------------\n "w" | Write-only, truncates existing file\n | to zero length or creates a new file for writing.\n -----+--------------------------------------------------------\n "w+" | Read-write, truncates existing file to zero length\n | or creates a new file for reading and writing.\n -----+--------------------------------------------------------\n "a" | Write-only, starts at end of file if file exists,\n | otherwise creates a new file for writing.\n -----+--------------------------------------------------------\n "a+" | Read-write, starts at end of file if file exists,\n | otherwise creates a new file for reading and\n | writing.\n -----+--------------------------------------------------------\n "b" | (DOS/Windows only) Binary file mode (may appear with\n | any of the key letters listed above).\n" - !ruby/struct:SM::Flow::P body: The global constant ARGF (also accessible as $<) provides an IO-like stream which allows access to all files mentioned on the command line (or STDIN if no files are mentioned). ARGF provides the methods #path and #filename to access the name of the file currently being read. constants: [] full_name: EOFError includes: [] instance_methods: [] name: EOFError superclass: IOError