Method: StringIO#each_line
- Defined in:
- ext/stringio/stringio.c
#each_line(sep = $/, chomp: false) {|line| ... } ⇒ self #each_line(limit, chomp: false) {|line| ... } ⇒ self #each_line(sep, limit, chomp: false) {|line| ... } ⇒ self
Calls the block with each remaining line read from the stream; does nothing if already at end-of-file; returns self. See Line IO.
1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 |
# File 'ext/stringio/stringio.c', line 1345 static VALUE strio_each(int argc, VALUE *argv, VALUE self) { VALUE line; struct getline_arg arg; StringIO(self); RETURN_ENUMERATOR(self, argc, argv); if (prepare_getline_args(&arg, argc, argv)->limit == 0) { rb_raise(rb_eArgError, "invalid limit: 0 for each_line"); } while (!NIL_P(line = strio_getline(&arg, readable(self)))) { rb_yield(line); } return self; } |