class YAML::PullParser
inherits Reference
¶
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.
Class methods¶
.new
¶
Creates a parser, yields it to the block, and closes the parser at the end of it.
Methods¶
#anchor
¶
Returns the anchor associated to the current event, or nil
if there's no anchor.
#mapping_style : MappingStyle
¶
: MappingStyle
Returns the mapping style, assuming the pull parser is located at a mapping begin event. Raises otherwise.
#raise(msg : String, line_number = self.start_line, column_number = self.start_column, context_info = nil)
¶
(msg : String, line_number = self.start_line, column_number = self.start_column, context_info = nil)
#read_document
¶
Reads a "document start" event, yields to the block, and then reads a "document end" event.
#read_mapping
¶
Reads a "mapping start" event, yields to the block, and then reads a "mapping end" event.
#read_sequence
¶
Reads a "sequence start" event, yields to the block, and then reads a "sequence end" event.
#read_stream
¶
Reads a "stream start" event, yields to the block, and then reads a "stream end" event.
#scalar_style : ScalarStyle
¶
: ScalarStyle
Returns the scalar style, assuming the pull parser is located at a scalar event. Raises otherwise.
#sequence_style : SequenceStyle
¶
: SequenceStyle
Returns the sequence style, assuming the pull parser is located at a sequence begin event. Raises otherwise.
#tag : String?
¶
: String?
Returns the tag associated to the current event, or nil
if there's no tag.
#value : String
¶
: String
Returns the scalar value, assuming the pull parser is located at a scalar. Raises otherwise.