class

YAML::PullParser

Inherits Reference / Object

A pull parser allows parsing a YAML document by events.

When creating an instance, the parser is positioned in the first event. To get the event kind invoke kind. If the event is a scalar you can invoke value to get its string value. Other methods like tag, anchor and scalar_style let you inspect other information from events.

Invoking read_next reads the next event.

Constructors

new(content : String | IO)
Source
new(content, &)

Creates a parser, yields it to the block, and closes the parser at the end of it.

Source

Instance methods

anchor

Returns the anchor associated to the current event, or nil if there's no anchor.

Source
close
Source
end_column
Source
end_line
Source
expect_kind(kind : EventKind) : Nil

Raises if the current kind is not the expected one.

Source
finalize
Source
kind

The current event kind.

Source
location
Source
mapping_style

Returns the mapping style, assuming the pull parser is located at a mapping begin event. Raises otherwise.

Source
raise(msg : String, line_number = self.start_line, column_number = self.start_column, context_info = nil) : NoReturn
Source
read(expected_kind : EventKind) : EventKind

Reads an expected event kind.

Source
read_alias

Reads an alias event, returning its anchor.

Source
read_document

Reads a "document start" event, yields to the block, and then reads a "document end" event.

Source
read_document_end

Reads a "document end" event.

Source
read_document_start

Reads a "document start" event.

Source
read_mapping

Reads a "mapping start" event, yields to the block, and then reads a "mapping end" event.

Source
read_mapping_end

Reads a "mapping end" event.

Source
read_mapping_start

Reads a "mapping start" event.

Source
read_next

Reads the next event.

Source
read_scalar

Reads a scalar, returning its value.

Source
read_sequence

Reads a "sequence start" event, yields to the block, and then reads a "sequence end" event.

Source
read_sequence_end

Reads a "sequence end" event.

Source
read_sequence_start

Reads a "sequence start" event.

Source
read_stream

Reads a "stream start" event, yields to the block, and then reads a "stream end" event.

Source
read_stream_end

Reads a "stream end" event.

Source
read_stream_start

Reads a "stream start" event.

Source
scalar_style

Returns the scalar style, assuming the pull parser is located at a scalar event. Raises otherwise.

Source
sequence_style

Returns the sequence style, assuming the pull parser is located at a sequence begin event. Raises otherwise.

Source
skip
Source
start_column
Source
start_line
Source
tag

Returns the tag associated to the current event, or nil if there's no tag.

Source
value

Returns the scalar value, assuming the pull parser is located at a scalar. Raises otherwise.

Source