123456789_123456789_123456789_123456789_123456789_

Class: Psych::Nodes::Sequence

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/sequence.rb

Overview

This class represents a YAML sequence.

A YAML sequence is basically a list, and looks like this:

%YAML 1.1
---
- I am
- a Sequence

A YAML sequence may have an anchor like this:

%YAML 1.1
---
&A [
  "This sequence",
  "has an anchor"
]

A YAML sequence may also have a tag like this:

%YAML 1.1
---
!!seq [
  "This sequence",
  "has a tag"
]

This class represents a sequence in a YAML document. A Sequence node may have 0 or more children. Valid children for this node are:

Constant Summary

Class Method Summary

Node - Inherited

.new

Create a new Node

Instance Attribute Summary

  • #anchor rw

    The anchor for this sequence (if any).

  • #implicit rw

    Is this sequence started implicitly?

  • #style rw

    The sequence style used.

  • #tag rw

    The tag name for this sequence (if any).

Node - Inherited

#children

The children of this node.

#tag

An associated tag.

Instance Method Summary

Node - Inherited

#each

Iterate over each node in the tree.

#to_ruby

Convert this node to Ruby.

#to_yaml
#transform
#yaml

Convert this node to YAML.

Constructor Details

.new(anchor = nil, tag = nil, implicit = true, style = BLOCK) ⇒ Sequence

Create a new object representing a YAML sequence.

#anchor is the anchor associated with the sequence or nil. #tag is the tag associated with the sequence or nil. #implicit a boolean indicating whether or not the sequence was implicitly started. #style is an integer indicating the list style.

See Handler#start_sequence

[ GitHub ]

  
# File 'ext/psych/lib/psych/nodes/sequence.rb', line 72

def initialize anchor = nil, tag = nil, implicit = true, style = BLOCK
  super()
  @anchor   = anchor
  @tag      = tag
  @implicit = implicit
  @style    = style
end

Instance Attribute Details

#anchor (rw)

The anchor for this sequence (if any)

[ GitHub ]

  
# File 'ext/psych/lib/psych/nodes/sequence.rb', line 51

attr_accessor :anchor

#implicit (rw)

Is this sequence started implicitly?

[ GitHub ]

  
# File 'ext/psych/lib/psych/nodes/sequence.rb', line 57

attr_accessor :implicit

#style (rw)

The sequence style used

[ GitHub ]

  
# File 'ext/psych/lib/psych/nodes/sequence.rb', line 60

attr_accessor :style

#tag (rw)

The tag name for this sequence (if any)

[ GitHub ]

  
# File 'ext/psych/lib/psych/nodes/sequence.rb', line 54

attr_accessor :tag