Class: Psych::Nodes::Document (Ruby 2.2.4)
Description: Class : Psych::Nodes::Document - Ruby 2.2.4

- Home
- Core 2.2.4
- Std-lib 2.2.4
- Downloads

Support for the Ruby 2.2 series has ended. See here for reference.

### Home Classes Methods

### In Files

- psych/lib/psych/nodes/document.rb

### Parent

Psych::Nodes::Node

### Methods

- ::new
- #root

### Class/Module Index

Quicksearch

- Kernel
- Module
- Object
- Psych
- Psych::BadAlias
- Psych::ClassLoader
- Psych::ClassLoader::Restricted
- Psych::Coder
- Psych::DisallowedClass
- Psych::Emitter
- Psych::Exception
- Psych::Handler
- Psych::Handler::DumperOptions
- Psych::Handlers
- Psych::Handlers::Recorder
- Psych::JSON
- Psych::JSON::Stream
- Psych::JSON::TreeBuilder
- Psych::Nodes
- Psych::Nodes::Alias
- Psych::Nodes::Document
- Psych::Nodes::Mapping
- Psych::Nodes::Node
- Psych::Nodes::Scalar
- Psych::Nodes::Sequence
- Psych::Nodes::Stream
- Psych::Omap
- Psych::Parser
- Psych::Parser::Mark
- Psych::ScalarScanner
- Psych::Set
- Psych::Stream
- Psych::Streaming
- Psych::Streaming::ClassMethods
- Psych::SyntaxError
- Psych::TreeBuilder
- Psych::Visitors
- Psych::Visitors::DepthFirst
- Psych::Visitors::Emitter
- Psych::Visitors::JSONTree
- Psych::Visitors::NoAliasRuby
- Psych::Visitors::ToRuby
- Psych::Visitors::Visitor
- Psych::Visitors::YAMLTree
- Regexp

No matching classes.

# Psych::Nodes::Document

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

### Attributes

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

### Public Class Methods

new(version = [], tag_directives = [], implicit = false) click to toggle source

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

                   # File psych/lib/psych/nodes/document.rb, line 44
    def initialize version = [], tag_directives = [], implicit = false
      super()
      @version        = version
      @tag_directives = tag_directives
      @implicit       = implicit
      @implicit_end   = true
    end

### Public Instance Methods

root() click to toggle source

Returns the root node. A Document may only have one root node: yaml.org/spec/1.1/#id898031

                   # File psych/lib/psych/nodes/document.rb, line 55
    def root
      children.first
    end