Method: ARGF#to_a
- Defined in:
- io.c
#readlines(sep = $/, chomp: false) ⇒ Array #readlines(limit, chomp: false) ⇒ Array #readlines(sep, limit, chomp: false) ⇒ Array
ARGF.to_a(sep = $/, chomp: false) -> array
ARGF.to_a(limit, chomp: false) -> array
ARGF.to_a(sep, limit, chomp: false) -> array
Reads each file in ARGF in its entirety, returning an Array containing lines from the files. Lines are assumed to be separated by sep.
lines = ARGF.readlines
lines[0] #=> "This is line one\n"
See IO.readlines for a full description of all options.
10575 10576 10577 10578 10579 10580 10581 10582 10583 10584 10585 10586 10587 10588 10589 10590 10591 10592 10593 10594 10595 10596 10597 |
# File 'io.c', line 10575
static VALUE
argf_readlines(int argc, VALUE *argv, VALUE argf)
{
long lineno = ARGF.lineno;
VALUE lines, ary;
ary = rb_ary_new();
while (next_argv()) {
if (ARGF_GENERIC_INPUT_P()) {
lines = forward_current(rb_intern("readlines"), argc, argv);
}
else {
lines = rb_io_readlines(argc, argv, ARGF.current_file);
argf_close(argf);
}
ARGF.next_p = 1;
rb_ary_concat(ary, lines);
ARGF.lineno = lineno + RARRAY_LEN(ary);
ARGF.last_lineno = ARGF.lineno;
}
ARGF.init_p = 0;
return ary;
}
|