File: C:/Ruby27-x64/share/doc/ruby/html/Psych/Handler.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>class Psych::Handler - RDoc Documentation</title>
<script type="text/javascript">
var rdoc_rel_prefix = "../";
var index_rel_prefix = "../";
</script>
<script src="../js/navigation.js" defer></script>
<script src="../js/search.js" defer></script>
<script src="../js/search_index.js" defer></script>
<script src="../js/searcher.js" defer></script>
<script src="../js/darkfish.js" defer></script>
<link href="../css/fonts.css" rel="stylesheet">
<link href="../css/rdoc.css" rel="stylesheet">
<body id="top" role="document" class="class">
<nav role="navigation">
<div id="project-navigation">
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
<h2>
<a href="../index.html" rel="home">Home</a>
</h2>
<div id="table-of-contents-navigation">
<a href="../table_of_contents.html#pages">Pages</a>
<a href="../table_of_contents.html#classes">Classes</a>
<a href="../table_of_contents.html#methods">Methods</a>
</div>
</div>
<div id="search-section" role="search" class="project-section initially-hidden">
<form action="#" method="get" accept-charset="utf-8">
<div id="search-field-wrapper">
<input id="search-field" role="combobox" aria-label="Search"
aria-autocomplete="list" aria-controls="search-results"
type="text" name="search" placeholder="Search" spellcheck="false"
title="Type to search, Up and Down to navigate, Enter to load">
</div>
<ul id="search-results" aria-label="Search Results"
aria-busy="false" aria-expanded="false"
aria-atomic="false" class="initially-hidden"></ul>
</form>
</div>
</div>
<div id="class-metadata">
<div id="parent-class-section" class="nav-section">
<h3>Parent</h3>
<p class="link"><a href="../Object.html">Object</a>
</div>
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
<h3>Methods</h3>
<ul class="link-list" role="directory">
<li ><a href="#method-i-alias">#alias</a>
<li ><a href="#method-i-empty">#empty</a>
<li ><a href="#method-i-end_document">#end_document</a>
<li ><a href="#method-i-end_mapping">#end_mapping</a>
<li ><a href="#method-i-end_sequence">#end_sequence</a>
<li ><a href="#method-i-end_stream">#end_stream</a>
<li ><a href="#method-i-event_location">#event_location</a>
<li ><a href="#method-i-scalar">#scalar</a>
<li ><a href="#method-i-start_document">#start_document</a>
<li ><a href="#method-i-start_mapping">#start_mapping</a>
<li ><a href="#method-i-start_sequence">#start_sequence</a>
<li ><a href="#method-i-start_stream">#start_stream</a>
<li ><a href="#method-i-streaming-3F">#streaming?</a>
</ul>
</div>
</div>
</nav>
<main role="main" aria-labelledby="class-Psych::Handler">
<h1 id="class-Psych::Handler" class="class">
class Psych::Handler
</h1>
<section class="description">
<p><a href="Handler.html"><code>Psych::Handler</code></a> is an abstract base class that defines the events used when dealing with <a href="Parser.html"><code>Psych::Parser</code></a>. Clients who want to use <a href="Parser.html"><code>Psych::Parser</code></a> should implement a class that inherits from <a href="Handler.html"><code>Psych::Handler</code></a> and define events that they can handle.</p>
<p><a href="Handler.html"><code>Psych::Handler</code></a> defines all events that <a href="Parser.html"><code>Psych::Parser</code></a> can possibly send to event handlers.</p>
<p>See <a href="Parser.html"><code>Psych::Parser</code></a> for more details</p>
</section>
<section id="5Buntitled-5D" class="documentation-section">
<section class="constants-list">
<header>
<h3>Constants</h3>
</header>
<dl>
<dt id="EVENTS">EVENTS
<dd><p>Events that a <a href="Handler.html"><code>Handler</code></a> should respond to.</p>
<dt id="OPTIONS">OPTIONS
<dd><p>Default dumping options</p>
</dl>
</section>
<section id="public-instance-5Buntitled-5D-method-details" class="method-section">
<header>
<h3>Public Instance Methods</h3>
</header>
<div id="method-i-alias" class="method-detail ">
<div class="method-heading">
<span class="method-name">alias</span><span
class="method-args">(anchor)</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>Called when an alias is found to <code>anchor</code>. <code>anchor</code> will be the name of the anchor found.</p>
<h3 id="method-i-alias-label-Example">Example<span><a href="#method-i-alias-label-Example">¶</a> <a href="#top">↑</a></span></h3>
<p>Here we have an example of an array that references itself in YAML:</p>
<pre>--- &ponies
- first element
- *ponies</pre>
<p>&ponies is the anchor, *ponies is the alias. In this case, alias is called with “ponies”.</p>
<div class="method-source-code" id="alias-source">
<pre><span class="ruby-comment"># File ext/psych/lib/psych/handler.rb, line 110</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">alias</span> <span class="ruby-identifier ruby-title">anchor</span>
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
<div id="method-i-empty" class="method-detail ">
<div class="method-heading">
<span class="method-name">empty</span><span
class="method-args">()</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>Called when an empty event happens. (Which, as far as I can tell, is never).</p>
<div class="method-source-code" id="empty-source">
<pre><span class="ruby-comment"># File ext/psych/lib/psych/handler.rb, line 236</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">empty</span>
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
<div id="method-i-end_document" class="method-detail ">
<div class="method-heading">
<span class="method-name">end_document</span><span
class="method-args">(implicit)</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>Called with the document ends. <code>implicit</code> is a boolean value indicating whether or not the document has an implicit ending.</p>
<h3 id="method-i-end_document-label-Example">Example<span><a href="#method-i-end_document-label-Example">¶</a> <a href="#top">↑</a></span></h3>
<p>Given the following YAML:</p>
<pre>---
hello world</pre>
<p><code>implicit</code> will be true. Given this YAML:</p>
<pre>---
hello world
...</pre>
<p><code>implicit</code> will be false.</p>
<div class="method-source-code" id="end_document-source">
<pre><span class="ruby-comment"># File ext/psych/lib/psych/handler.rb, line 93</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">end_document</span> <span class="ruby-identifier">implicit</span>
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
<div id="method-i-end_mapping" class="method-detail ">
<div class="method-heading">
<span class="method-name">end_mapping</span><span
class="method-args">()</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>Called when a map ends</p>
<div class="method-source-code" id="end_mapping-source">
<pre><span class="ruby-comment"># File ext/psych/lib/psych/handler.rb, line 230</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">end_mapping</span>
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
<div id="method-i-end_sequence" class="method-detail ">
<div class="method-heading">
<span class="method-name">end_sequence</span><span
class="method-args">()</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>Called when a sequence ends.</p>
<div class="method-source-code" id="end_sequence-source">
<pre><span class="ruby-comment"># File ext/psych/lib/psych/handler.rb, line 191</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">end_sequence</span>
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
<div id="method-i-end_stream" class="method-detail ">
<div class="method-heading">
<span class="method-name">end_stream</span><span
class="method-args">()</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>Called when the YAML stream ends</p>
<div class="method-source-code" id="end_stream-source">
<pre><span class="ruby-comment"># File ext/psych/lib/psych/handler.rb, line 241</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">end_stream</span>
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
<div id="method-i-event_location" class="method-detail ">
<div class="method-heading">
<span class="method-name">event_location</span><span
class="method-args">(start_line, start_column, end_line, end_column)</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>Called before each event with line/column information.</p>
<div class="method-source-code" id="event_location-source">
<pre><span class="ruby-comment"># File ext/psych/lib/psych/handler.rb, line 246</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">event_location</span>(<span class="ruby-identifier">start_line</span>, <span class="ruby-identifier">start_column</span>, <span class="ruby-identifier">end_line</span>, <span class="ruby-identifier">end_column</span>)
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
<div id="method-i-scalar" class="method-detail ">
<div class="method-heading">
<span class="method-name">scalar</span><span
class="method-args">(value, anchor, tag, plain, quoted, style)</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>Called when a scalar <code>value</code> is found. The scalar may have an <code>anchor</code>, a <code>tag</code>, be implicitly <code>plain</code> or implicitly <code>quoted</code></p>
<p><code>value</code> is the string value of the scalar <code>anchor</code> is an associated anchor or nil <code>tag</code> is an associated tag or nil <code>plain</code> is a boolean value <code>quoted</code> is a boolean value <code>style</code> is an integer idicating the string style</p>
<p>See the constants in <a href="Nodes/Scalar.html"><code>Psych::Nodes::Scalar</code></a> for the possible values of <code>style</code></p>
<h3 id="method-i-scalar-label-Example">Example<span><a href="#method-i-scalar-label-Example">¶</a> <a href="#top">↑</a></span></h3>
<p>Here is a YAML document that exercises most of the possible ways this method can be called:</p>
<pre>---
- !str "foo"
- &anchor fun
- many
lines
- |
many
newlines</pre>
<p>The above YAML document contains a list with four strings. Here are the parameters sent to this method in the same order:</p>
<pre class="ruby"><span class="ruby-comment"># value anchor tag plain quoted style</span>
[<span class="ruby-string">"foo"</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-string">"!str"</span>, <span class="ruby-keyword">false</span>, <span class="ruby-keyword">false</span>, <span class="ruby-value">3</span> ]
[<span class="ruby-string">"fun"</span>, <span class="ruby-string">"anchor"</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">true</span>, <span class="ruby-keyword">false</span>, <span class="ruby-value">1</span> ]
[<span class="ruby-string">"many lines"</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">true</span>, <span class="ruby-keyword">false</span>, <span class="ruby-value">1</span> ]
[<span class="ruby-string">"many\nnewlines\n"</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">false</span>, <span class="ruby-keyword">true</span>, <span class="ruby-value">4</span> ]
</pre>
<div class="method-source-code" id="scalar-source">
<pre><span class="ruby-comment"># File ext/psych/lib/psych/handler.rb, line 150</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">scalar</span> <span class="ruby-identifier">value</span>, <span class="ruby-identifier">anchor</span>, <span class="ruby-identifier">tag</span>, <span class="ruby-identifier">plain</span>, <span class="ruby-identifier">quoted</span>, <span class="ruby-identifier">style</span>
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
<div id="method-i-start_document" class="method-detail ">
<div class="method-heading">
<span class="method-name">start_document</span><span
class="method-args">(version, tag_directives, implicit)</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>Called when the document starts with the declared <code>version</code>, <code>tag_directives</code>, if the document is <code>implicit</code>.</p>
<p><code>version</code> will be an array of integers indicating the YAML version being dealt with, <code>tag_directives</code> is a list of tuples indicating the prefix and suffix of each tag, and <code>implicit</code> is a boolean indicating whether the document is started implicitly.</p>
<h3 id="method-i-start_document-label-Example">Example<span><a href="#method-i-start_document-label-Example">¶</a> <a href="#top">↑</a></span></h3>
<p>Given the following YAML:</p>
<pre>%YAML 1.1
%TAG ! tag:tenderlovemaking.com,2009:
--- !squee</pre>
<p>The parameters for <a href="Handler.html#method-i-start_document"><code>start_document</code></a> must be this:</p>
<pre class="ruby"><span class="ruby-identifier">version</span> <span class="ruby-comment"># => [1, 1]</span>
<span class="ruby-identifier">tag_directives</span> <span class="ruby-comment"># => [["!", "tag:tenderlovemaking.com,2009:"]]</span>
<span class="ruby-identifier">implicit</span> <span class="ruby-comment"># => false</span>
</pre>
<div class="method-source-code" id="start_document-source">
<pre><span class="ruby-comment"># File ext/psych/lib/psych/handler.rb, line 72</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">start_document</span> <span class="ruby-identifier">version</span>, <span class="ruby-identifier">tag_directives</span>, <span class="ruby-identifier">implicit</span>
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
<div id="method-i-start_mapping" class="method-detail ">
<div class="method-heading">
<span class="method-name">start_mapping</span><span
class="method-args">(anchor, tag, implicit, style)</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>Called when a map starts.</p>
<p><code>anchor</code> is the anchor associated with the map or <code>nil</code>. <code>tag</code> is the tag associated with the map or <code>nil</code>. <code>implicit</code> is a boolean indicating whether or not the map was implicitly started. <code>style</code> is an integer indicating the mapping style.</p>
<p>See the constants in <a href="Nodes/Mapping.html"><code>Psych::Nodes::Mapping</code></a> for the possible values of <code>style</code>.</p>
<h3 id="method-i-start_mapping-label-Example">Example<span><a href="#method-i-start_mapping-label-Example">¶</a> <a href="#top">↑</a></span></h3>
<p>Here is a YAML document that exercises most of the possible ways this method can be called:</p>
<pre>---
k: !!map { hello: world }
v: &pewpew
hello: world</pre>
<p>The above YAML document consists of three maps, an outer map that contains two inner maps. Below is a matrix of the parameters sent in order to represent these three maps:</p>
<pre class="ruby"><span class="ruby-comment"># anchor tag implicit style</span>
[<span class="ruby-keyword">nil</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">true</span>, <span class="ruby-value">1</span> ]
[<span class="ruby-keyword">nil</span>, <span class="ruby-string">"tag:yaml.org,2002:map"</span>, <span class="ruby-keyword">false</span>, <span class="ruby-value">2</span> ]
[<span class="ruby-string">"pewpew"</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">true</span>, <span class="ruby-value">1</span> ]
</pre>
<div class="method-source-code" id="start_mapping-source">
<pre><span class="ruby-comment"># File ext/psych/lib/psych/handler.rb, line 225</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">start_mapping</span> <span class="ruby-identifier">anchor</span>, <span class="ruby-identifier">tag</span>, <span class="ruby-identifier">implicit</span>, <span class="ruby-identifier">style</span>
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
<div id="method-i-start_sequence" class="method-detail ">
<div class="method-heading">
<span class="method-name">start_sequence</span><span
class="method-args">(anchor, tag, implicit, style)</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>Called when a sequence is started.</p>
<p><code>anchor</code> is the anchor associated with the sequence or nil. <code>tag</code> is the tag associated with the sequence or nil. <code>implicit</code> a boolean indicating whether or not the sequence was implicitly started. <code>style</code> is an integer indicating the list style.</p>
<p>See the constants in <a href="Nodes/Sequence.html"><code>Psych::Nodes::Sequence</code></a> for the possible values of <code>style</code>.</p>
<h3 id="method-i-start_sequence-label-Example">Example<span><a href="#method-i-start_sequence-label-Example">¶</a> <a href="#top">↑</a></span></h3>
<p>Here is a YAML document that exercises most of the possible ways this method can be called:</p>
<pre>---
- !!seq [
a
]
- &pewpew
- b</pre>
<p>The above YAML document consists of three lists, an outer list that contains two inner lists. Here is a matrix of the parameters sent to represent these lists:</p>
<pre class="ruby"><span class="ruby-comment"># anchor tag implicit style</span>
[<span class="ruby-keyword">nil</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">true</span>, <span class="ruby-value">1</span> ]
[<span class="ruby-keyword">nil</span>, <span class="ruby-string">"tag:yaml.org,2002:seq"</span>, <span class="ruby-keyword">false</span>, <span class="ruby-value">2</span> ]
[<span class="ruby-string">"pewpew"</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">true</span>, <span class="ruby-value">1</span> ]
</pre>
<div class="method-source-code" id="start_sequence-source">
<pre><span class="ruby-comment"># File ext/psych/lib/psych/handler.rb, line 186</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">start_sequence</span> <span class="ruby-identifier">anchor</span>, <span class="ruby-identifier">tag</span>, <span class="ruby-identifier">implicit</span>, <span class="ruby-identifier">style</span>
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
<div id="method-i-start_stream" class="method-detail ">
<div class="method-heading">
<span class="method-name">start_stream</span><span
class="method-args">(encoding)</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>Called with <code>encoding</code> when the YAML stream starts. This method is called once per stream. A stream may contain multiple documents.</p>
<p>See the constants in <a href="Parser.html"><code>Psych::Parser</code></a> for the possible values of <code>encoding</code>.</p>
<div class="method-source-code" id="start_stream-source">
<pre><span class="ruby-comment"># File ext/psych/lib/psych/handler.rb, line 47</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">start_stream</span> <span class="ruby-identifier">encoding</span>
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
<div id="method-i-streaming-3F" class="method-detail ">
<div class="method-heading">
<span class="method-name">streaming?</span><span
class="method-args">()</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>Is this handler a streaming handler?</p>
<div class="method-source-code" id="streaming-3F-source">
<pre><span class="ruby-comment"># File ext/psych/lib/psych/handler.rb, line 251</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">streaming?</span>
<span class="ruby-keyword">false</span>
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
</section>
</section>
</main>
<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.1.1.
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
</footer>