blob: 32014d60dc909631e37752ef447e0d4ad842e5e3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
module Psych
module Nodes
###
# This represents a YAML Document. This node must be a child of
# Psych::Nodes::Stream. A Psych::Nodes::Document must have one child,
# and that child may be one of the following:
#
# * Psych::Nodes::Sequence
# * Psych::Nodes::Mapping
# * Psych::Nodes::Scalar
class Document < Psych::Nodes::Node
# The version of the YAML document
attr_accessor :version
# A list of tag directives for this document
attr_accessor :tag_directives
# Was this document implicitly created?
attr_accessor :implicit
# Is the end of the document implicit?
attr_accessor :implicit_end
###
# Create a new Psych::Nodes::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 Psych::Handler#start_document
def initialize version = [], tag_directives = [], implicit = false
super()
@version = version
@tag_directives = tag_directives
@implicit = implicit
@implicit_end = true
end
###
# Returns the root node. A Document may only have one root node:
# http://yaml.org/spec/1.1/#id898031
def root
children.first
end
end
end
end
|