W3cubDocs

/Crystal

class YAML::PullParser

Overview

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.

Defined in:

yaml/pull_parser.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(content : String | IO)Source

def self.new(content, &)Source

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

Instance Method Detail

def anchorSource

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

def closeSource

def end_columnSource

def end_lineSource

def expect_kind(kind : EventKind)Source

Raises if the current kind is not the expected one.

def finalizeSource

def kind : EventKindSource

The current event kind.

def locationSource

def mapping_style : MappingStyleSource

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

def raise(msg : String, line_number = self.start_line, column_number = self.start_column, context_info = nil)Source

def read(expected_kind : EventKind) : EventKindSource

Reads an expected event kind.

def read_aliasSource

Reads an alias event, returning its anchor.

def read_document(&)Source

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

def read_document_endSource

Reads a "document end" event.

def read_document_startSource

Reads a "document start" event.

def read_mapping(&)Source

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

def read_mapping_endSource

Reads a "mapping end" event.

def read_mapping_startSource

Reads a "mapping start" event.

def read_next : EventKindSource

Reads the next event.

def read_scalarSource

Reads a scalar, returning its value.

def read_sequence(&)Source

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

def read_sequence_endSource

Reads a "sequence end" event.

def read_sequence_startSource

Reads a "sequence start" event.

def read_stream(&)Source

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

def read_stream_endSource

Reads a "stream end" event.

def read_stream_startSource

Reads a "stream start" event.

def scalar_style : ScalarStyleSource

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

def sequence_style : SequenceStyleSource

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

def skipSource

def start_columnSource

def start_lineSource

def tag : String?Source

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

def value : StringSource

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

© 2012–2020 Manas Technology Solutions.
Licensed under the Apache License, Version 2.0.
https://crystal-lang.org/api/0.35.1/YAML/PullParser.html