readlines(*args) public

Reads all of the lines in ios, and returns them in an array. 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 an 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 an IOError will be raised.

f ="testfile")
f.readlines[0]   #=> "This is line one\n"

f ="testfile", chomp: true)
f.readlines[0]   #=> "This is line one"

See IO.readlines for details about getline_args.

Show source
Register or log in to add new notes.