Class: Psych::Nodes::Document
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
Node
|
|
Instance Chain:
self,
Node,
Enumerable
|
|
Inherits: |
Psych::Nodes::Node
|
Defined in: | ext/psych/lib/psych/nodes/document.rb |
Overview
Class Method Summary
-
.new(version = [], tag_directives = [], implicit = false) ⇒ Document
constructor
Create a new
Document
object.
Node - Inherited
Instance Attribute Summary
-
#implicit
rw
Was this document implicitly created?
-
#implicit_end
rw
Is the end of the document implicit?
-
#tag_directives
rw
A list of tag directives for this document.
-
#version
rw
The version of the YAML document.
Node - Inherited
Instance Method Summary
-
#root
Returns the root node.
Node - Inherited
#each | Iterate over each node in the tree. |
#to_ruby | Convert this node to Ruby. |
#to_yaml | |
#transform | Alias for Node#to_ruby. |
#yaml | Convert this node to YAML. |
Constructor Details
.new(version = [], tag_directives = [], implicit = false) ⇒ Document
Create a new Document
object.
#version is a list indicating the YAML version. tags_directives
is a list of tag directive declarations #implicit is a flag indicating whether the document will be implicitly started.
Example:
This creates a YAML document object that represents a YAML 1.1 document with one tag directive, and has an implicit start:
Psych::Nodes::Document.new(
[1,1],
[["!", "tag:tenderlovemaking.com,2009:"]],
true
)
See Also
See also Handler#start_document
# File 'ext/psych/lib/psych/nodes/document.rb', line 45
def initialize version = [], tag_directives = [], implicit = false super() @version = version @tag_directives = tag_directives @implicit = implicit @implicit_end = true end
Instance Attribute Details
#implicit (rw)
Was this document implicitly created?
# File 'ext/psych/lib/psych/nodes/document.rb', line 20
attr_accessor :implicit
#implicit_end (rw)
Is the end of the document implicit?
# File 'ext/psych/lib/psych/nodes/document.rb', line 23
attr_accessor :implicit_end
#tag_directives (rw)
A list of tag directives for this document
# File 'ext/psych/lib/psych/nodes/document.rb', line 17
attr_accessor :tag_directives
#version (rw)
The version of the YAML document
# File 'ext/psych/lib/psych/nodes/document.rb', line 14
attr_accessor :version
Instance Method Details
#root
Returns the root node. A Document may only have one root node: yaml.org/spec/1.1/#id898031
# File 'ext/psych/lib/psych/nodes/document.rb', line 56
def root children.first end