class

Crst::LineReader

Inherits Reference < Object

Helper class for iterating over lines of text

Constructors

new(lines : Array(String))
Source

Instance methods

advance(count : Int32 = 1)

Advance the reader by count lines

Source
consume_until

Consume lines until the block returns true (or EOF) The line that satisfies the condition is NOT consumed Returns the consumed lines

Source
current

Returns the current line Raises IndexError if out of bounds

Source
current?

Returns the current line or nil if out of bounds

Source
eof?

Check if the reader is at the end

Source
has_next?

Check if there are more lines to read

Source
index
Source
lines
Source
peek(offset : Int32 = 1) : String | Nil

Returns the line at offset from current position peek(1) is the next line

Source
skip_empty_lines

Skip empty lines

Source
slice(start_index : Int32) : Array(String)

Returns a slice of lines from start (inclusive) to current (exclusive)

Source