End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Pathname#each_line
pathname.each_line {|line| ... }
pathname.each_line(sep=$/ [, open_args]) {|line| block } → nil
pathname.each_line(limit [, open_args]) {|line| block } → nil
pathname.each_line(sep, limit [, open_args]) {|line| block } → nil
pathname.each_line(...) → an_enumerator
ext/pathname/pathname.c
View on GitHub ↗
static VALUE
path_each_line(int argc, VALUE *argv, VALUE self)
{
VALUE args[4];
int n;
args[0] = get_strpath(self);
n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]);
if (rb_block_given_p()) {
return rb_block_call_kw(rb_cFile, id_foreach, 1+n, args, 0, 0, RB_PASS_CALLED_KEYWORDS);
}
else {
return rb_funcallv_kw(rb_cFile, id_foreach, 1+n, args, RB_PASS_CALLED_KEYWORDS);
}
}
Iterates over each line in the file and yields a String object for each.