1module Psych
2  module Nodes
3    ###
4    # This class represents a
5    # {YAML sequence}[http://yaml.org/spec/1.1/#sequence/syntax].
6    #
7    # A YAML sequence is basically a list, and looks like this:
8    #
9    #   %YAML 1.1
10    #   ---
11    #   - I am
12    #   - a Sequence
13    #
14    # A YAML sequence may have an anchor like this:
15    #
16    #   %YAML 1.1
17    #   ---
18    #   &A [
19    #     "This sequence",
20    #     "has an anchor"
21    #   ]
22    #
23    # A YAML sequence may also have a tag like this:
24    #
25    #   %YAML 1.1
26    #   ---
27    #   !!seq [
28    #     "This sequence",
29    #     "has a tag"
30    #   ]
31    #
32    # This class represents a sequence in a YAML document.  A
33    # Psych::Nodes::Sequence node may have 0 or more children.  Valid children
34    # for this node are:
35    #
36    # * Psych::Nodes::Sequence
37    # * Psych::Nodes::Mapping
38    # * Psych::Nodes::Scalar
39    # * Psych::Nodes::Alias
40    class Sequence < Psych::Nodes::Node
41      # Any Styles, emitter chooses
42      ANY   = 0
43
44      # Block style sequence
45      BLOCK = 1
46
47      # Flow style sequence
48      FLOW  = 2
49
50      # The anchor for this sequence (if any)
51      attr_accessor :anchor
52
53      # The tag name for this sequence (if any)
54      attr_accessor :tag
55
56      # Is this sequence started implicitly?
57      attr_accessor :implicit
58
59      # The sequece style used
60      attr_accessor :style
61
62      ###
63      # Create a new object representing a YAML sequence.
64      #
65      # +anchor+ is the anchor associated with the sequence or nil.
66      # +tag+ is the tag associated with the sequence or nil.
67      # +implicit+ a boolean indicating whether or not the sequence was
68      # implicitly started.
69      # +style+ is an integer indicating the list style.
70      #
71      # See Psych::Handler#start_sequence
72      def initialize anchor = nil, tag = nil, implicit = true, style = BLOCK
73        super()
74        @anchor   = anchor
75        @tag      = tag
76        @implicit = implicit
77        @style    = style
78      end
79    end
80  end
81end
82