scanf

scanf(str) Instance Public methods Scans the current string until the match is exhausted, yielding each match as it is encountered in the string. A block is not necessary though, as the results will simply be aggregated into the final array. "123 456".block_scanf("%d") # => [123, 456] If a block is given, the value from that is returned from the yield is added to an output array. "123 456".block_scanf("%d) do |digit,| # the ',' unpacks the Array digit + 100 end # => [223,

rewind

ios.rewind â 0 Instance Public methods Positions ios to the beginning of input, resetting lineno to zero. f = File.new("testfile") f.readline #=> "This is line one\n" f.rewind #=> 0 f.lineno #=> 0 f.readline #=> "This is line one\n" Note that it cannot be used with streams such as pipes, ttys, and sockets.

reopen

ios.reopen(other_IO) â iosios.reopen(path, mode_str) â ios Instance Public methods Reassociates ios with the I/O stream given in other_IO or to a new stream opened on path. This may dynamically change the actual class of this stream. f1 = File.new("testfile") f2 = File.new("testfile") f2.readlines[0] #=> "This is line one\n" f2.reopen(f1) #=> #<File:testfile> f2.readlines[0] #=> "This is line one\n"

ready?

io.ready? â true, false or nil Instance Public methods Returns true if input available without blocking, or false. Returns nil if no information available.

readpartial

ios.readpartial(maxlen) â stringios.readpartial(maxlen, outbuf) â outbuf Instance Public methods Reads at most maxlen bytes from the I/O stream. It blocks only if ios has no data immediately available. It doesn't block if some data available. If the optional outbuf argument is present, it must reference a String, which will receive the data. The outbuf will contain only the received data after the method call even if it is not empty at the beginning. It raises EO

readlines 2

ios.readlines(sep=$/) â arrayios.readlines(limit) â arrayios.readlines(sep, limit) â array Instance Public methods Reads all of the lines in ios, and returns them in anArray. Lines are separated by the optional sep. If sep is nil, the rest of the stream is returned as a single record. If the first argument is an integer, or optional second argument is given, the returning string would not be longer than the given value in bytes. The stream must be opened for reading or a

readline

ios.readline(sep=$/) â stringios.readline(limit) â stringios.readline(sep, limit) â string Instance Public methods Reads a line as with IO#gets, but raises an EOFError on end of file.

readchar

ios.readchar â string Instance Public methods Reads a one-character string from ios. Raises an EOFError on end of file. f = File.new("testfile") f.readchar #=> "h" f.readchar #=> "e"

readbyte

ios.readbyte â fixnum Instance Public methods Reads a byte as with IO#getbyte, but raises an EOFError on end of file.

read_nonblock

ios.read_nonblock(maxlen) â stringios.read_nonblock(maxlen, outbuf) â outbuf Instance Public methods Reads at most maxlen bytes from ios using the read(2) system call after O_NONBLOCK is set for the underlying file descriptor. If the optional outbuf argument is present, it must reference a String, which will receive the data. The outbuf will contain only the received data after the method call even if it is not empty at the beginning. #read_nonblock just calls th