class Crst::LineReader

Overview

Helper class for iterating over lines of text

Defined in:

crst/line_reader.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(lines : Array(String)) #

[View source]

Instance Method Detail

def advance(count : Int32 = 1) #

Advance the reader by count lines


[View source]
def consume_until(&) : Array(String) #

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


[View source]
def current : String #

Returns the current line Raises IndexError if out of bounds


[View source]
def current? : String | Nil #

Returns the current line or nil if out of bounds


[View source]
def eof? #

Check if the reader is at the end


[View source]
def has_next? #

Check if there are more lines to read


[View source]
def index : Int32 #

[View source]
def lines : Array(String) #

[View source]
def peek(offset : Int32 = 1) : String | Nil #

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


[View source]
def skip_empty_lines #

Skip empty lines


[View source]
def slice(start_index : Int32) : Array(String) #

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


[View source]