U:RDoc::NormalModule[iI" Nodes:EFI"Psych::Nodes;T0o:RDoc::Markup::Document: @parts[ o;;[#S:RDoc::Markup::Heading: leveli: textI" Overview;To:RDoc::Markup::BlankLineo:RDoc::Markup::Paragraph;[I"KWhen using Psych.load to deserialize a YAML document, the document is ;TI"Gtranslated to an intermediary AST. That intermediary AST is then ;TI"*translated in to a Ruby object graph.;T@o; ;[I"PIn the opposite direction, when using Psych.dump, the Ruby object graph is ;TI"Itranslated to an intermediary AST which is then converted to a YAML ;TI"document.;T@o; ;[ I"OPsych::Nodes contains all of the classes that make up the nodes of a YAML ;TI"JAST. You can manually build an AST and use one of the visitors (see ;TI"LPsych::Visitors) to convert that AST to either a YAML document or to a ;TI"Ruby object graph.;T@o; ;[I"KHere is an example of building an AST that represents a list with one ;TI" scalar:;T@o:RDoc::Markup::Verbatim;[I"# Create our nodes ;TI"'stream = Psych::Nodes::Stream.new ;TI")doc = Psych::Nodes::Document.new ;TI")seq = Psych::Nodes::Sequence.new ;TI".scalar = Psych::Nodes::Scalar.new('foo') ;TI" ;TI"# Build up our tree ;TI"stream.children << doc ;TI"doc.children << seq ;TI"seq.children << scalar ;T: @format0o; ;[I"OThe stream is the root of the tree. We can then convert the tree to YAML:;T@o;;[I"&stream.to_yaml => "---\n- foo\n" ;T;0o; ;[I"Or convert it to Ruby:;T@o;;[I"!stream.to_ruby => [["foo"]] ;T;0S; ; i; I"YAML AST Requirements;T@o; ;[I"KA valid YAML AST *must* have one Psych::Nodes::Stream at the root. A ;TI"PPsych::Nodes::Stream node must have 1 or more Psych::Nodes::Document nodes ;TI"as children.;T@o; ;[I"RPsych::Nodes::Document nodes must have one and *only* one child. That child ;TI"may be one of:;T@o:RDoc::Markup::List: @type: BULLET: @items[o:RDoc::Markup::ListItem: @label0;[o; ;[I"Psych::Nodes::Sequence;To;;0;[o; ;[I"Psych::Nodes::Mapping;To;;0;[o; ;[I"Psych::Nodes::Scalar;T@o; ;[I"JPsych::Nodes::Sequence and Psych::Nodes::Mapping nodes may have many ;TI"Mchildren, but Psych::Nodes::Mapping nodes should have an even number of ;TI"children.;T@o; ;[I"DAll of these are valid children for Psych::Nodes::Sequence and ;TI"!Psych::Nodes::Mapping nodes:;T@o;;;;[ o;;0;[o; ;[I"Psych::Nodes::Sequence;To;;0;[o; ;[I"Psych::Nodes::Mapping;To;;0;[o; ;[I"Psych::Nodes::Scalar;To;;0;[o; ;[I"Psych::Nodes::Alias;T@o; ;[I"NPsych::Nodes::Scalar and Psych::Nodes::Alias are both terminal nodes and ;TI""should not have any children.;T: @fileI"!ext/psych/lib/psych/nodes.rb;T:0@omit_headings_from_table_of_contents_below0o;;[;I"'ext/psych/lib/psych/nodes/alias.rb;T;0o;;[;I"*ext/psych/lib/psych/nodes/document.rb;T;0o;;[;I")ext/psych/lib/psych/nodes/mapping.rb;T;0o;;[;I"&ext/psych/lib/psych/nodes/node.rb;T;0o;;[;I"(ext/psych/lib/psych/nodes/scalar.rb;T;0o;;[;I"*ext/psych/lib/psych/nodes/sequence.rb;T;0o;;[;I"(ext/psych/lib/psych/nodes/stream.rb;T;0;0;0[[[[[I" class;T[[: public[[:protected[[: private[[I" instance;T[[;[[;[[;[[[U:RDoc::Context::Section[i0o;;[;0;0[@{@~@|@@‚@…@ˆ@‹I"(ext/psych/lib/psych/tree_builder.rb;TI",ext/psych/lib/psych/visitors/to_ruby.rb;TI".ext/psych/lib/psych/visitors/yaml_tree.rb;TI"lib/rubygems/psych_tree.rb;TI" Psych;FcRDoc::NormalModule