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

Node - Inherited

#alias?,
#children

The children of this node.

#document?,
#end_column

The column number where this node ends.

#end_line

The line number where this node ends.

#mapping?, #scalar?, #sequence?,
#start_column

The column number where this node start.

#start_line

The line number where this node start.

#stream?,
#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 73

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 52

attr_accessor :anchor

#implicit (rw)

Is this sequence started implicitly?

[ GitHub ]

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

attr_accessor :implicit

#sequence?Boolean (readonly)

[ GitHub ]

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

def sequence?; true; end

#style (rw)

The sequence style used

[ GitHub ]

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

attr_accessor :style

#tag (rw)

The tag name for this sequence (if any)

[ GitHub ]

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

attr_accessor :tag