We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 599bfd4 commit fbe0b4eCopy full SHA for fbe0b4e
1 file changed
lib/piperator/io.rb
@@ -49,6 +49,13 @@ def gets(separator = $INPUT_RECORD_SEPARATOR, _limit = nil)
49
read_with { @buffer.gets(separator) }
50
end
51
52
+ # Returns an enumerator of lines in the stream, without reading the entire stream into memory
53
+ #
54
+ # @return [Enumerator]
55
+ def each_line
56
+ Enumerator.new { |y| loop { y << gets } }.lazy.take_while(&:itself).each
57
+ end
58
+
59
# Flush internal buffer until the last unread byte
60
def flush
61
if @buffer.pos == @buffer_read_pos
0 commit comments