D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
IO
/
Filename :
cdesc-IO.ri
back
Copy
U:RDoc::NormalClass[iI"IO:ET@I"Object;To:RDoc::Markup::Document:@parts[ o;;[ : @fileI"ext/io/console/console.c;T:0@omit_headings_from_table_of_contents_below0o;;[ ; I"ext/pty/lib/expect.rb;T; 0o;;[�o:RDoc::Markup::Paragraph;[I";An instance of class \IO (commonly called a _stream_) ;TI"Krepresents an input/output stream in the underlying operating system. ;TI":\Class \IO is the basis for input and output in Ruby.;To:RDoc::Markup::BlankLine o;;[I"O\Class File is the only class in the Ruby core that is a subclass of \IO. ;TI"KSome classes in the Ruby standard library are also subclasses of \IO; ;TI"+these include TCPSocket and UDPSocket.;T@o;;[ I"?The global constant ARGF (also accessible as <tt>$<</tt>) ;TI"Eprovides an IO-like stream that allows access to all file paths ;TI"9found in ARGV (or found in STDIN if ARGV is empty). ;TI"*ARGF is not itself a subclass of \IO.;T@o;;[I"G\Class StringIO provides an IO-like stream that handles a String. ;TI".StringIO is not itself a subclass of \IO.;T@o;;[I",Important objects based on \IO include:;T@o:RDoc::Markup::List: @type:BULLET:@items[ o:RDoc::Markup::ListItem:@label0;[o;;[I"$stdin.;To;;0;[o;;[I" $stdout.;To;;0;[o;;[I" $stderr.;To;;0;[o;;[I"Instances of class File.;T@o;;[I"-An instance of \IO may be created using:;T@o; ;;;[ o;;0;[o;;[I"LIO.new: returns a new \IO object for the given integer file descriptor.;To;;0;[o;;[I"9IO.open: passes a new \IO object to the given block.;To;;0;[o;;[I"TIO.popen: returns a new \IO object that is connected to the $stdin and $stdout ;TI"$of a newly-launched subprocess.;To;;0;[o;;[I"HKernel#open: Returns a new \IO object connected to a given source: ;TI"!stream, file, or subprocess.;T@o;;[I"+Like a File stream, an \IO stream has:;T@o; ;;;[o;;0;[o;;[I"KA read/write mode, which may be read-only, write-only, or read/write; ;TI"<see {Read/Write Mode}[rdoc-ref:File@Read-2FWrite+Mode].;To;;0;[o;;[I"4A data mode, which may be text-only or binary; ;TI".see {Data Mode}[rdoc-ref:File@Data+Mode].;To;;0;[o;;[I"&Internal and external encodings; ;TI".see {Encodings}[rdoc-ref:File@Encodings].;T@o;;[I"(And like other \IO streams, it has:;T@o; ;;;[o;;0;[o;;[I"?A position, which determines where in the stream the next ;TI" read or write is to occur; ;TI"*see {Position}[rdoc-ref:IO@Position].;To;;0;[o;;[I"BA line number, which is a special, line-oriented, "position" ;TI"4(different from the position mentioned above); ;TI"0see {Line Number}[rdoc-ref:IO@Line+Number].;T@S:RDoc::Markup::Heading: leveli: textI""Extension <tt>io/console</tt>;T@o;;[I"=Extension <tt>io/console</tt> provides numerous methods ;TI"'for interacting with the console; ;TI"5requiring it adds numerous methods to class \IO.;T@S;;i;I"Example Files;T@o;;[I",Many examples here use these variables:;T@o:RDoc::Markup::Verbatim;[I"## English text with newlines. ;TI"text = <<~EOT ;TI" First line ;TI" Second line ;TI" ;TI" Fourth line ;TI" Fifth line ;TI" EOT ;TI" ;TI"# Russian text. ;TI"5russian = "\u{442 435 441 442}" # => "тест" ;TI" ;TI"# Binary data. ;TI"-data = "\u9990\u9991\u9992\u9993\u9994" ;TI" ;TI"# Text file. ;TI"File.write('t.txt', text) ;TI" ;TI"# File with Russian text. ;TI""File.write('t.rus', russian) ;TI" ;TI"# File with binary data. ;TI"(f = File.new('t.dat', 'wb:UTF-16') ;TI"f.write(data) ;TI" f.close ;T:@format0S;;i;I"Open Options;T@o;;[I"?A number of \IO methods accept optional keyword arguments ;TI"5that determine how a new stream is to be opened:;T@o; ;;;[o;;0;[o;;[I"+:mode+: Stream mode.;To;;0;[o;;[I"(+:flags+: Integer file open flags; ;TI"7If +mode+ is also given, the two are bitwise-ORed.;To;;0;[o;;[I"<+:external_encoding+: External encoding for the stream.;To;;0;[o;;[I"=+:internal_encoding+: Internal encoding for the stream. ;TI"B<tt>'-'</tt> is a synonym for the default internal encoding. ;TI"0If the value is +nil+ no conversion occurs.;To;;0;[o;;[I"X+:encoding+: Specifies external and internal encodings as <tt>'extern:intern'</tt>.;To;;0;[o;;[I"W+:textmode+: If a truthy value, specifies the mode as text-only, binary otherwise.;To;;0;[o;;[I"V+:binmode+: If a truthy value, specifies the mode as binary, text-only otherwise.;To;;0;[o;;[I"I+:autoclose+: If a truthy value, specifies that the +fd+ will close ;TI"7when the stream closes; otherwise it remains open.;To;;0;[o;;[I"X+:path:+ If a string value is provided, it is used in #inspect and is available as ;TI"#path method.;T@o;;[I">Also available are the options offered in String#encode, ;TI"Iwhich may control conversion between external and internal encoding.;T@S;;i;I"Basic \IO;T@o;;[I":You can perform basic stream \IO with these methods, ;TI"3which typically operate on multi-byte strings:;T@o; ;;;[o;;0;[o;;[I"SIO#read: Reads and returns some or all of the remaining bytes from the stream.;To;;0;[o;;[I":IO#write: Writes zero or more strings to the stream; ;TI"Leach given object that is not already a string is converted via +to_s+.;T@S;;i;I" Position;T@o;;[ I"9An \IO stream has a nonnegative integer _position_, ;TI"Kwhich is the byte offset at which the next read or write is to occur. ;TI"<A new stream has position zero (and line number zero); ;TI"Cmethod +rewind+ resets the position (and line number) to zero.;T@o;;[I"DThese methods discard {buffers}[rdoc-ref:IO@Buffering] and the ;TI"5Encoding::Converter instances used for that \IO.;T@o;;[I"The relevant methods:;T@o; ;;;[ o;;0;[o;;[I"XIO#tell (aliased as +#pos+): Returns the current position (in bytes) in the stream.;To;;0;[o;;[I"[IO#pos=: Sets the position of the stream to a given integer +new_position+ (in bytes).;To;;0;[o;;[I"VIO#seek: Sets the position of the stream to a given integer +offset+ (in bytes), ;TI"+relative to a given position +whence+ ;TI":(indicating the beginning, end, or current position).;To;;0;[o;;[I"WIO#rewind: Positions the stream at the beginning (also resetting the line number).;T@S;;i;I"Open and Closed Streams;T@o;;[I"IA new \IO stream may be open for reading, open for writing, or both.;T@o;;[I"LA stream is automatically closed when claimed by the garbage collector.;T@o;;[I"IAttempted reading or writing on a closed stream raises an exception.;T@o;;[I"The relevant methods:;T@o; ;;;[ o;;0;[o;;[I">IO#close: Closes the stream for both reading and writing.;To;;0;[o;;[I"2IO#close_read: Closes the stream for reading.;To;;0;[o;;[I"3IO#close_write: Closes the stream for writing.;To;;0;[o;;[I"6IO#closed?: Returns whether the stream is closed.;T@S;;i;I"End-of-Stream;T@o;;[I"=You can query whether a stream is positioned at its end:;T@o; ;;;[o;;0;[o;;[I"VIO#eof? (also aliased as +#eof+): Returns whether the stream is at end-of-stream.;T@o;;[I"AYou can reposition to end-of-stream by using method IO#seek:;T@o;;[ I"f = File.new('t.txt') ;TI"f.eof? # => false ;TI"f.seek(0, :END) ;TI"f.eof? # => true ;TI" f.close ;T;0o;;[I"KOr by reading all stream content (which is slower than using IO#seek):;T@o;;[ I"f.rewind ;TI"f.eof? # => false ;TI"Hf.read # => "First line\nSecond line\n\nFourth line\nFifth line\n" ;TI"f.eof? # => true ;T;0S;;i;I" Line \IO;T@o;;[I"'\Class \IO supports line-oriented ;TI"J{input}[rdoc-ref:IO@Line+Input] and {output}[rdoc-ref:IO@Line+Output];T@S;;i;I"Line Input;T@o;;[I"1\Class \IO supports line-oriented input for ;TI"Y{files}[rdoc-ref:IO@File+Line+Input] and {IO streams}[rdoc-ref:IO@Stream+Line+Input];T@S;;i ;I"\File Line Input;T@o;;[I"8You can read lines from a file using these methods:;T@o; ;;;[o;;0;[o;;[I"BIO.foreach: Reads each line and passes it to the given block.;To;;0;[o;;[I";IO.readlines: Reads and returns all lines in an array.;T@o;;[I"For each of these methods:;T@o; ;;;[o;;0;[o;;[I">You can specify {open options}[rdoc-ref:IO@Open+Options].;To;;0;[o;;[I"BLine parsing depends on the effective <i>line separator</i>; ;TI"6see {Line Separator}[rdoc-ref:IO@Line+Separator].;To;;0;[o;;[I"RThe length of each returned line depends on the effective <i>line limit</i>; ;TI".see {Line Limit}[rdoc-ref:IO@Line+Limit].;T@S;;i ;I"Stream Line Input;T@o;;[I"?You can read lines from an \IO stream using these methods:;T@o; ;;;[ o;;0;[o;;[I"LIO#each_line: Reads each remaining line, passing it to the given block.;To;;0;[o;;[I"$IO#gets: Returns the next line.;To;;0;[o;;[I"GIO#readline: Like #gets, but raises an exception at end-of-stream.;To;;0;[o;;[I";IO#readlines: Returns all remaining lines in an array.;T@o;;[I"For each of these methods:;T@o; ;;;[o;;0;[o;;[I"!Reading may begin mid-line, ;TI"+depending on the stream's _position_; ;TI"*see {Position}[rdoc-ref:IO@Position].;To;;0;[o;;[I"BLine parsing depends on the effective <i>line separator</i>; ;TI"6see {Line Separator}[rdoc-ref:IO@Line+Separator].;To;;0;[o;;[I"RThe length of each returned line depends on the effective <i>line limit</i>; ;TI".see {Line Limit}[rdoc-ref:IO@Line+Limit].;T@S;;i ;I"Line Separator;T@o;;[I"\Each of the {line input methods}[rdoc-ref:IO@Line+Input] uses a <i>line separator</i>: ;TI";the string that determines what is considered a line; ;TI">it is sometimes called the <i>input record separator</i>.;T@o;;[I"KThe default line separator is taken from global variable <tt>$/</tt>, ;TI"*whose initial value is <tt>"\n"</tt>.;T@o;;[ I"5Generally, the line to be read next is all data ;TI"7from the current {position}[rdoc-ref:IO@Position] ;TI" to the next line separator ;TI"Z(but see {Special Line Separator Values}[rdoc-ref:IO@Special+Line+Separator+Values]):;T@o;;[ I"f = File.new('t.txt') ;TI"P# Method gets with no sep argument returns the next line, according to $/. ;TI" f.gets # => "First line\n" ;TI"!f.gets # => "Second line\n" ;TI"f.gets # => "\n" ;TI"!f.gets # => "Fourth line\n" ;TI" f.gets # => "Fifth line\n" ;TI" f.close ;T;0o;;[I"FYou can use a different line separator by passing argument +sep+:;T@o;;[I"f = File.new('t.txt') ;TI""f.gets('l') # => "First l" ;TI")f.gets('li') # => "ine\nSecond li" ;TI"+f.gets('lin') # => "ne\n\nFourth lin" ;TI"f.gets # => "e\n" ;TI" f.close ;T;0o;;[I"/Or by setting global variable <tt>$/</tt>:;T@o;;[I"f = File.new('t.txt') ;TI"$/ = 'l' ;TI"f.gets # => "First l" ;TI"!f.gets # => "ine\nSecond l" ;TI"#f.gets # => "ine\n\nFourth l" ;TI" f.close ;T;0S;;i ;I""Special Line Separator Values;T@o;;[I">Each of the {line input methods}[rdoc-ref:IO@Line+Input] ;TI"4accepts two special values for parameter +sep+:;T@o; ;;;[o;;0;[o;;[I"M+nil+: The entire stream is to be read ("slurped") into a single string:;T@o;;[I"f = File.new('t.txt') ;TI"Mf.gets(nil) # => "First line\nSecond line\n\nFourth line\nFifth line\n" ;TI" f.close ;T;0o;;0;[o;;[I"H<tt>''</tt> (the empty string): The next "paragraph" is to be read ;TI"E(paragraphs being separated by two consecutive line separators):;T@o;;[ I"f = File.new('t.txt') ;TI"3f.gets('') # => "First line\nSecond line\n\n" ;TI"1f.gets('') # => "Fourth line\nFifth line\n" ;TI" f.close ;T;0S;;i ;I"Line Limit;T@o;;[ I">Each of the {line input methods}[rdoc-ref:IO@Line+Input] ;TI"(uses an integer <i>line limit</i>, ;TI"?which restricts the number of bytes that may be returned. ;TI"^(A multi-byte character will not be split, and so a returned line may be slightly longer ;TI"than the limit).;T@o;;[I"-The default limit value is <tt>-1</tt>; ;TI";any negative limit value means that there is no limit.;T@o;;[I"@If there is no limit, the line is determined only by +sep+.;T@o;;[I"$# Text with 1-byte characters. ;TI"3File.open('t.txt') {|f| f.gets(1) } # => "F" ;TI"4File.open('t.txt') {|f| f.gets(2) } # => "Fi" ;TI"5File.open('t.txt') {|f| f.gets(3) } # => "Fir" ;TI"6File.open('t.txt') {|f| f.gets(4) } # => "Firs" ;TI"# No more than one line. ;TI"<File.open('t.txt') {|f| f.gets(10) } # => "First line" ;TI">File.open('t.txt') {|f| f.gets(11) } # => "First line\n" ;TI">File.open('t.txt') {|f| f.gets(12) } # => "First line\n" ;TI" ;TI"=# Text with 2-byte characters, which will not be split. ;TI"5File.open('t.rus') {|f| f.gets(1).size } # => 1 ;TI"5File.open('t.rus') {|f| f.gets(2).size } # => 1 ;TI"5File.open('t.rus') {|f| f.gets(3).size } # => 2 ;TI"5File.open('t.rus') {|f| f.gets(4).size } # => 2 ;T;0S;;i ;I""Line Separator and Line Limit;T@o;;[I"HWith arguments +sep+ and +limit+ given, combines the two behaviors:;T@o; ;;;[o;;0;[o;;[I"AReturns the next line as determined by line separator +sep+.;To;;0;[o;;[I"EBut returns no more bytes than are allowed by the limit +limit+.;T@o;;[I" Example:;T@o;;[I"@File.open('t.txt') {|f| f.gets('li', 20) } # => "First li" ;TI":File.open('t.txt') {|f| f.gets('li', 2) } # => "Fi" ;T;0S;;i ;I"Line Number;T@o;;[I"IA readable \IO stream has a non-negative integer <i>line number</i>:;T@o; ;;;[o;;0;[o;;[I"(IO#lineno: Returns the line number.;To;;0;[o;;[I"4IO#lineno=: Resets and returns the line number.;T@o;;[ I"5Unless modified by a call to method IO#lineno=, ;TI"1the line number is the number of lines read ;TI"'by certain line-oriented methods, ;TI"Maccording to the effective {line separator}[rdoc-ref:IO@Line+Separator]:;T@o; ;;;[ o;;0;[o;;[I"FIO.foreach: Increments the line number on each call to the block.;To;;0;[o;;[I"HIO#each_line: Increments the line number on each call to the block.;To;;0;[o;;[I")IO#gets: Increments the line number.;To;;0;[o;;[I"-IO#readline: Increments the line number.;To;;0;[o;;[I"AIO#readlines: Increments the line number for each line read.;T@o;;[I"IA new stream is initially has line number zero (and position zero); ;TI"Cmethod +rewind+ resets the line number (and position) to zero:;T@o;;[I"f = File.new('t.txt') ;TI"f.lineno # => 0 ;TI""f.gets # => "First line\n" ;TI"f.lineno # => 1 ;TI"f.rewind ;TI"f.lineno # => 0 ;TI" f.close ;T;0o;;[I"AReading lines from a stream usually changes its line number:;T@o;;[I" f = File.new('t.txt', 'r') ;TI"f.lineno # => 0 ;TI"+f.readline # => "This is line one.\n" ;TI"f.lineno # => 1 ;TI"2f.readline # => "This is the second line.\n" ;TI"f.lineno # => 2 ;TI"0f.readline # => "Here's the third line.\n" ;TI"f.lineno # => 3 ;TI"f.eof? # => true ;TI" f.close ;T;0o;;[I"FIterating over lines in a stream usually changes its line number:;T@o;;[ I"File.open('t.txt') do |f| ;TI" f.each_line do |line| ;TI"A p "position=#{f.pos} eof?=#{f.eof?} lineno=#{f.lineno}" ;TI" end ;TI" end ;T;0o;;[I"Output:;T@o;;[ I"'"position=11 eof?=false lineno=1" ;TI"'"position=23 eof?=false lineno=2" ;TI"'"position=24 eof?=false lineno=3" ;TI"'"position=36 eof?=false lineno=4" ;TI"&"position=47 eof?=true lineno=5" ;T;0o;;[I";Unlike the stream's {position}[rdoc-ref:IO@Position], ;TI"Mthe line number does not affect where the next read or write will occur:;T@o;;[I"f = File.new('t.txt') ;TI"f.lineno = 1000 ;TI"f.lineno # => 1000 ;TI""f.gets # => "First line\n" ;TI"f.lineno # => 1001 ;TI" f.close ;T;0o;;[I"HAssociated with the line number is the global variable <tt>$.</tt>:;T@o; ;;;[o;;0;[o;;[I"6When a stream is opened, <tt>$.</tt> is not set; ;TI"Bits value is left over from previous activity in the process:;T@o;;[ I" $. = 41 ;TI"f = File.new('t.txt') ;TI" $. = 41 ;TI" # => 41 ;TI" f.close ;T;0o;;0;[o;;[I"RWhen a stream is read, <tt>$.</tt> is set to the line number for that stream:;T@o;;[ I"f0 = File.new('t.txt') ;TI"f1 = File.new('t.dat') ;TI"`f0.readlines # => ["First line\n", "Second line\n", "\n", "Fourth line\n", "Fifth line\n"] ;TI"$. # => 5 ;TI"Lf1.readlines # => ["\xFE\xFF\x99\x90\x99\x91\x99\x92\x99\x93\x99\x94"] ;TI"$. # => 1 ;TI"f0.close ;TI"f1.close ;T;0o;;0;[o;;[I"=Methods IO#rewind and IO#seek do not affect <tt>$.</tt>:;T@o;;[I"f = File.new('t.txt') ;TI"_f.readlines # => ["First line\n", "Second line\n", "\n", "Fourth line\n", "Fifth line\n"] ;TI"$. # => 5 ;TI"f.rewind ;TI"f.seek(0, :SET) ;TI"$. # => 5 ;TI" f.close ;T;0S;;i;I"Line Output;T@o;;[I"CYou can write to an \IO stream line-by-line using this method:;T@o; ;;;[o;;0;[o;;[I"+IO#puts: Writes objects to the stream.;T@S;;i;I"Character \IO;T@o;;[I"NYou can process an \IO stream character-by-character using these methods:;T@o; ;;;[ o;;0;[o;;[I"CIO#getc: Reads and returns the next character from the stream.;To;;0;[o;;[I"GIO#readchar: Like #getc, but raises an exception at end-of-stream.;To;;0;[o;;[I"PIO#ungetc: Pushes back ("unshifts") a character or integer onto the stream.;To;;0;[o;;[I"/IO#putc: Writes a character to the stream.;To;;0;[o;;[I"AIO#each_char: Reads each remaining character in the stream, ;TI".passing the character to the given block.;T@S;;i;I" Byte \IO;T@o;;[I"DYou can process an \IO stream byte-by-byte using these methods:;T@o; ;;;[ o;;0;[o;;[I"KIO#getbyte: Returns the next 8-bit byte as an integer in range 0..255.;To;;0;[o;;[I"MIO#readbyte: Like #getbyte, but raises an exception if at end-of-stream.;To;;0;[o;;[I"HIO#ungetbyte: Pushes back ("unshifts") a byte back onto the stream.;To;;0;[o;;[I"<IO#each_byte: Reads each remaining byte in the stream, ;TI")passing the byte to the given block.;T@S;;i;I"Codepoint \IO;T@o;;[I":You can process an \IO stream codepoint-by-codepoint:;T@o; ;;;[o;;0;[o;;[I"VIO#each_codepoint: Reads each remaining codepoint, passing it to the given block.;T@S;;i;I"What's Here;T@o;;[I")First, what's elsewhere. \Class \IO:;T@o; ;;;[o;;0;[o;;[I"AInherits from {class Object}[rdoc-ref:Object@What-27s+Here].;To;;0;[o;;[I"FIncludes {module Enumerable}[rdoc-ref:Enumerable@What-27s+Here], ;TI"1which provides dozens of additional methods.;T@o;;[I":Here, class \IO provides methods that are useful for:;T@o; ;;;[o;;0;[o;;[I"%{Creating}[rdoc-ref:IO@Creating];To;;0;[o;;[I"#{Reading}[rdoc-ref:IO@Reading];To;;0;[o;;[I"#{Writing}[rdoc-ref:IO@Writing];To;;0;[o;;[I"+{Positioning}[rdoc-ref:IO@Positioning];To;;0;[o;;[I"'{Iterating}[rdoc-ref:IO@Iterating];To;;0;[o;;[I"%{Settings}[rdoc-ref:IO@Settings];To;;0;[o;;[I"%{Querying}[rdoc-ref:IO@Querying];To;;0;[o;;[I"'{Buffering}[rdoc-ref:IO@Buffering];To;;0;[o;;[I"5{Low-Level Access}[rdoc-ref:IO@Low-Level+Access];To;;0;[o;;[I"{Other}[rdoc-ref:IO@Other];T@S;;i;I" Creating;T@o; ;;;[ o;;0;[o;;[I"U::new (aliased as ::for_fd): Creates and returns a new \IO object for the given ;TI"integer file descriptor.;To;;0;[o;;[I"&::open: Creates a new \IO object.;To;;0;[o;;[I"G::pipe: Creates a connected pair of reader and writer \IO objects.;To;;0;[o;;[I"B::popen: Creates an \IO object to interact with a subprocess.;To;;0;[o;;[I"H::select: Selects which given \IO instances are ready for reading, ;TI")writing, or have pending exceptions.;T@S;;i;I"Reading;T@o; ;;;[o;;0;[o;;[I"F::binread: Returns a binary string with all or a subset of bytes ;TI"from the given file.;To;;0;[o;;[I"P::read: Returns a string with all or a subset of bytes from the given file.;To;;0;[o;;[I"W::readlines: Returns an array of strings, which are the lines from the given file.;To;;0;[o;;[I"J#getbyte: Returns the next 8-bit byte read from +self+ as an integer.;To;;0;[o;;[I"D#getc: Returns the next character read from +self+ as a string.;To;;0;[o;;[I".#gets: Returns the line read from +self+.;To;;0;[o;;[I"A#pread: Returns all or the next _n_ bytes read from +self+, ;TI"(not updating the receiver's offset.;To;;0;[o;;[I"I#read: Returns all remaining or the next _n_ bytes read from +self+ ;TI"for a given _n_.;To;;0;[o;;[I"J#read_nonblock: the next _n_ bytes read from +self+ for a given _n_, ;TI"in non-block mode.;To;;0;[o;;[I"8#readbyte: Returns the next byte read from +self+; ;TI"@same as #getbyte, but raises an exception on end-of-stream.;To;;0;[o;;[I"=#readchar: Returns the next character read from +self+; ;TI"=same as #getc, but raises an exception on end-of-stream.;To;;0;[o;;[I"8#readline: Returns the next line read from +self+; ;TI"@same as #getline, but raises an exception of end-of-stream.;To;;0;[o;;[I"E#readlines: Returns an array of all lines read read from +self+.;To;;0;[o;;[I"G#readpartial: Returns up to the given number of bytes from +self+.;T@S;;i;I"Writing;T@o; ;;;[o;;0;[o;;[I"L::binwrite: Writes the given string to the file at the given filepath, ;TI"in binary mode.;To;;0;[o;;[I"0::write: Writes the given string to +self+.;To;;0;[o;;[I"-#<<: Appends the given string to +self+.;To;;0;[o;;[I">#print: Prints last read line or given objects to +self+.;To;;0;[o;;[I"L#printf: Writes to +self+ based on the given format string and objects.;To;;0;[o;;[I")#putc: Writes a character to +self+.;To;;0;[o;;[I"I#puts: Writes lines to +self+, making sure line ends with a newline.;To;;0;[o;;[I";#pwrite: Writes the given string at the given offset, ;TI"(not updating the receiver's offset.;To;;0;[o;;[I"8#write: Writes one or more given strings to +self+.;To;;0;[o;;[I"V#write_nonblock: Writes one or more given strings to +self+ in non-blocking mode.;T@S;;i;I"Positioning;T@o; ;;;[o;;0;[o;;[I"8#lineno: Returns the current line number in +self+.;To;;0;[o;;[I".#lineno=: Sets the line number is +self+.;To;;0;[o;;[I"H#pos (aliased as #tell): Returns the current byte offset in +self+.;To;;0;[o;;[I"+#pos=: Sets the byte offset in +self+.;To;;0;[o;;[I"D#reopen: Reassociates +self+ with a new or existing \IO stream.;To;;0;[o;;[I"9#rewind: Positions +self+ to the beginning of input.;To;;0;[o;;[I"B#seek: Sets the offset for +self+ relative to given position.;T@S;;i;I"Iterating;T@o; ;;;[ o;;0;[o;;[I"<::foreach: Yields each line of given file to the block.;To;;0;[o;;[I":#each (aliased as #each_line): Calls the given block ;TI")with each successive line in +self+.;To;;0;[o;;[I"K#each_byte: Calls the given block with each successive byte in +self+ ;TI"as an integer.;To;;0;[o;;[I"P#each_char: Calls the given block with each successive character in +self+ ;TI"as a string.;To;;0;[o;;[I"U#each_codepoint: Calls the given block with each successive codepoint in +self+ ;TI"as an integer.;T@S;;i;I" Settings;T@o; ;;;[o;;0;[o;;[I"2#autoclose=: Sets whether +self+ auto-closes.;To;;0;[o;;[I"*#binmode: Sets +self+ to binary mode.;To;;0;[o;;[I"#close: Closes +self+.;To;;0;[o;;[I"2#close_on_exec=: Sets the close-on-exec flag.;To;;0;[o;;[I",#close_read: Closes +self+ for reading.;To;;0;[o;;[I"-#close_write: Closes +self+ for writing.;To;;0;[o;;[I"1#set_encoding: Sets the encoding for +self+.;To;;0;[o;;[I"F#set_encoding_by_bom: Sets the encoding for +self+, based on its ;TI"Unicode byte-order-mark.;To;;0;[o;;[I"3#sync=: Sets the sync-mode to the given value.;T@S;;i;I" Querying;T@o; ;;;[o;;0;[o;;[I"5#autoclose?: Returns whether +self+ auto-closes.;To;;0;[o;;[I"9#binmode?: Returns whether +self+ is in binary mode.;To;;0;[o;;[I"@#close_on_exec?: Returns the close-on-exec flag for +self+.;To;;0;[o;;[I"0#closed?: Returns whether +self+ is closed.;To;;0;[o;;[I"I#eof? (aliased as #eof): Returns whether +self+ is at end-of-stream.;To;;0;[o;;[I"I#external_encoding: Returns the external encoding object for +self+.;To;;0;[o;;[I"O#fileno (aliased as #to_i): Returns the integer file descriptor for +self+;To;;0;[o;;[I"I#internal_encoding: Returns the internal encoding object for +self+.;To;;0;[o;;[I"M#pid: Returns the process ID of a child process associated with +self+, ;TI"&if +self+ was created by ::popen.;To;;0;[o;;[I"S#stat: Returns the File::Stat object containing status information for +self+.;To;;0;[o;;[I"3#sync: Returns whether +self+ is in sync-mode.;To;;0;[o;;[I"F#tty? (aliased as #isatty): Returns whether +self+ is a terminal.;T@S;;i;I"Buffering;T@o; ;;;[ o;;0;[o;;[I"H#fdatasync: Immediately writes all buffered data in +self+ to disk.;To;;0;[o;;[I"G#flush: Flushes any buffered data within +self+ to the underlying ;TI"operating system.;To;;0;[o;;[I"S#fsync: Immediately writes all buffered data and attributes in +self+ to disk.;To;;0;[o;;[I"N#ungetbyte: Prepends buffer for +self+ with given integer byte or string.;To;;0;[o;;[I";#ungetc: Prepends buffer for +self+ with given string.;T@S;;i;I"Low-Level Access;T@o; ;;;[o;;0;[o;;[I"2::sysopen: Opens the file given by its path, ;TI"+returning the integer file descriptor.;To;;0;[o;;[I"S#advise: Announces the intention to access data from +self+ in a specific way.;To;;0;[o;;[I">#fcntl: Passes a low-level command to the file specified ;TI""by the given file descriptor.;To;;0;[o;;[I"@#ioctl: Passes a low-level command to the device specified ;TI""by the given file descriptor.;To;;0;[o;;[I"V#sysread: Returns up to the next _n_ bytes read from self using a low-level read.;To;;0;[o;;[I"*#sysseek: Sets the offset for +self+.;To;;0;[o;;[I"J#syswrite: Writes the given string to +self+ using a low-level write.;T@S;;i;I" Other;T@o; ;;;[o;;0;[o;;[I"@::copy_stream: Copies data from a source to a destination, ;TI"7each of which is a filepath or an \IO-like object.;To;;0;[o;;[I"G::try_convert: Returns a new \IO object resulting from converting ;TI"the given object.;To;;0;[o;;[I";#inspect: Returns the string representation of +self+.;T; I" io.c;T; 0o;;[ ; I" io.rb;T; 0; 0; 0[ [U:RDoc::Constant[i I" READABLE;TI"IO::READABLE;T:public0o;;[o;;[I"%Readable event mask for IO#wait.;T@; @L; 0@L@cRDoc::NormalClass0U;[i I" WRITABLE;TI"IO::WRITABLE;T;0o;;[o;;[I"%Writable event mask for IO#wait.;T@; @L; 0@L@@[0U;[i I" PRIORITY;TI"IO::PRIORITY;T;0o;;[o;;[I"%Priority event mask for IO#wait.;T@; @L; 0@L@@[0U;[i I"EWOULDBLOCKWaitReadable;TI" IO::EWOULDBLOCKWaitReadable;T;0o;;[o;;[I"#same as IO::EAGAINWaitReadable;T@; @L; 0@L@@[0U;[i I"EWOULDBLOCKWaitWritable;TI" IO::EWOULDBLOCKWaitWritable;T;0o;;[o;;[I"#same as IO::EAGAINWaitWritable;T@; @L; 0@L@@[0U;[i I" SEEK_SET;TI"IO::SEEK_SET;T;0o;;[o;;[I"(Set I/O position from the beginning;T@; @L; 0@L@@[0U;[i I" SEEK_CUR;TI"IO::SEEK_CUR;T;0o;;[o;;[I"/Set I/O position from the current position;T@; @L; 0@L@@[0U;[i I" SEEK_END;TI"IO::SEEK_END;T;0o;;[o;;[I""Set I/O position from the end;T@; @L; 0@L@@[0U;[i I"SEEK_DATA;TI"IO::SEEK_DATA;T;0o;;[o;;[I":Set I/O position to the next location containing data;T@; @L; 0@L@@[0U;[i I"SEEK_HOLE;TI"IO::SEEK_HOLE;T;0o;;[o;;[I"&Set I/O position to the next hole;T@; @L; 0@L@@[0[[I"File::Constants;To;;[ ; I"file.c;T; 0I"file.c;T[I"Enumerable;To;;[ ; @L; 0I" io.c;T[[I" class;T[[;[[I"binread;T@�[I" binwrite;T@�[I"console;TI"ext/io/console/console.c;T[I"copy_stream;T@�[I"for_fd;T@�[I"foreach;T@�[I"new;T@�[I" open;T@�[I" pipe;T@�[I" popen;T@�[I" read;T@�[I"readlines;T@�[I"select;T@�[I"sysopen;T@�[I"try_convert;T@�[I" write;T@�[:protected[ [:private[ [I" instance;T[[;[z[I"<<;T@�[I"advise;T@�[I"autoclose=;T@�[I"autoclose?;T@�[I" beep;T@�[I"binmode;T@�[I" binmode?;T@�[I"check_winsize_changed;T@�[I"clear_screen;T@�[I" close;T@�[I"close_on_exec=;T@�[I"close_on_exec?;T@�[I"close_read;T@�[I"close_write;T@�[I"closed?;T@�[I"console_mode;T@�[I"console_mode=;T@�[I"cooked;T@�[I"cooked!;T@�[I"cursor;T@�[I"cursor=;T@�[I"cursor_down;T@�[I"cursor_left;T@�[I"cursor_right;T@�[I"cursor_up;T@�[I" each;T@�[I"each_byte;T@�[I"each_char;T@�[I"each_codepoint;T@�[I"each_line;T@�[I" echo=;T@�[I" echo?;T@�[I"eof;T@�[I" eof?;T@�[I"erase_line;T@�[I"erase_screen;T@�[I"expect;TI"ext/pty/lib/expect.rb;T[I"external_encoding;T@�[I" fcntl;T@�[I"fdatasync;T@�[I"fileno;T@�[I" flush;T@�[I" fsync;T@�[I"getbyte;T@�[I" getc;T@�[I" getch;T@�[I"getpass;T@�[I" gets;T@�[I" goto;T@�[I"goto_column;T@�[I"iflush;T@�[I"inspect;T@�[I"internal_encoding;T@�[I" ioctl;T@�[I"ioflush;T@�[I"isatty;T@�[I"lineno;T@�[I"lineno=;T@�[I"noecho;T@�[I" nonblock;TI"ext/io/nonblock/nonblock.c;T[I"nonblock=;T@b[I"nonblock?;T@b[I" nread;TI"ext/io/wait/wait.c;T[I"oflush;T@�[I" path;T@�[I" pathconf;TI"ext/etc/etc.c;T[I"pid;T@�[I"pos;T@�[I" pos=;T@�[I" pread;T@�[I" pressed?;T@�[I" print;T@�[I"printf;T@�[I" putc;T@�[I" puts;T@�[I"pwrite;T@�[I"raw;T@�[I" raw!;T@�[I" read;T@�[I"read_nonblock;TI" io.rb;T[I" readbyte;T@�[I" readchar;T@�[I" readline;T@�[I"readlines;T@�[I"readpartial;T@�[I"ready?;T@i[I"reopen;T@�[I"rewind;T@�[I"scroll_backward;T@�[I"scroll_forward;T@�[I" seek;T@�[I"set_encoding;T@�[I"set_encoding_by_bom;T@�[I" stat;T@�[I" sync;T@�[I" sync=;T@�[I"sysread;T@�[I"sysseek;T@�[I" syswrite;T@�[I" tell;T@�[I"timeout;T@�[I" timeout=;T@�[I" to_i;T@�[I" to_io;T@�[I"to_path;T@�[I" tty?;T@�[I"ttyname;T@�[I"ungetbyte;T@�[I"ungetc;T@�[I" wait;T@i[I"wait_priority;T@i[I"wait_readable;T@i[I"wait_writable;T@i[I"winsize;T@�[I" winsize=;T@�[I" write;T@�[I"write_nonblock;T@�[;[ [;[ [ [U:RDoc::Context::Section[i 0o;;[ ; 0; 0[I"ext/etc/etc.c;T@ I"ext/io/nonblock/nonblock.c;TI"ext/io/wait/wait.c;T@@�@L@OI"lib/rubygems.rb;TI"-lib/rubygems/package/tar_reader/entry.rb;TI"lib/rubygems/resolver.rb;TI"lib/rubygems/util.rb;T@OcRDoc::TopLevel