/* * call-seq: * ios.readlines(sep_string=$/) => array * * Reads all of the lines in <em>ios</em>, and returns them in * <i>anArray</i>. Lines are separated by the optional * <i>sep_string</i>. If <i>sep_string</i> is <code>nil</code>, the * rest of the stream is returned as a single record. * The stream must be opened for reading or an * <code>IOError</code> will be raised. * * f = File.new("testfile") * f.readlines[0] #=> "This is line one\n" */ static VALUE rb_io_readlines(argc, argv, io) int argc; VALUE *argv; VALUE io; { VALUE line, ary; VALUE rs; if (argc == 0) { rs = rb_rs; } else { rb_scan_args(argc, argv, "1", &rs); if (!NIL_P(rs)) StringValue(rs); } ary = rb_ary_new(); while (!NIL_P(line = rb_io_getline(rs, io))) { rb_ary_push(ary, line); } return ary; }