The IO class provides basic IO functions.
Converts the stream into binary mode. The only way to revert to normal mode is to reopen the stream.
Returns self.
Closes the IO port. An Errno::EXXX exception is thrown if close fails.
Returns nil.
Reads from the IO port line by line.
Returns self.
Reads from the IO port byte by byte.
Returns self.
Returns true if the stream reaches the end of the file.
Returns the current position of the file pointer.
Moves the file pointer to the indicated position.
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.
Reads all the data and returns an array whose elements consist of the lines that were 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 line feeds will be treated as line separators (paragraph mode).
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.