IO

The IO class provides basic IO functions.

Superclass

Included Modules

Methods

binmode

Converts the stream into binary mode. The only way to revert to normal mode is to reopen the stream.

Returns self.

close

Closes the IO port. An Errno::EXXX exception is thrown if close fails.

Returns nil.

each_line {|line| ... }

Reads from the IO port line by line.

Returns self.

each_byte {|ch| ... }

Reads from the IO port byte by byte.

Returns self.

eof?

Returns true when the stream reaches the end of the file.

pos

Returns the current position of the file pointer.

pos=n

Moves the file pointer to the indicated position.

read([length])

Reads length bytes and returns the string. If length is omitted, reads all data until the end of the file.

If the IO has already reached the end of the file, returns nil.

Throws an Errno::EXXX exception if the data read fails and an ArgumentError exception if length is negative.

readlines([rs])

Reads all the data and returns an array whose elements consist of the lines read. If the IO has already reached the end of the file, returns the empty array [].

Lines are separated by the string indicated in the argument rs, whose default value is "\n".

Specify nil for rs and the lines will not be separated. Specify the empty string "" and consecutive linefeeds will be treated as line separators (paragraph mode).

write(str)

Outputs str to the IO port. If str is not a string, tries converting it to a string with to_s.

Returns the actual number of bytes written. Throws an Errno::EXXX exception if the output action fails.

Converted from CHM to HTML with chm2web Pro 2.85 (unicode)