1module Psych
2  module Nodes
3    ###
4    # This class represents a {YAML Mapping}[http://yaml.org/spec/1.1/#mapping].
5    #
6    # A Psych::Nodes::Mapping node may have 0 or more children, but must have
7    # an even number of children.  Here are the valid children a
8    # Psych::Nodes::Mapping node may have:
9    #
10    # * Psych::Nodes::Sequence
11    # * Psych::Nodes::Mapping
12    # * Psych::Nodes::Scalar
13    # * Psych::Nodes::Alias
14    class Mapping < Psych::Nodes::Node
15      # Any Map Style
16      ANY   = 0
17
18      # Block Map Style
19      BLOCK = 1
20
21      # Flow Map Style
22      FLOW  = 2
23
24      # The optional anchor for this mapping
25      attr_accessor :anchor
26
27      # The optional tag for this mapping
28      attr_accessor :tag
29
30      # Is this an implicit mapping?
31      attr_accessor :implicit
32
33      # The style of this mapping
34      attr_accessor :style
35
36      ###
37      # Create a new Psych::Nodes::Mapping object.
38      #
39      # +anchor+ is the anchor associated with the map or +nil+.
40      # +tag+ is the tag associated with the map or +nil+.
41      # +implicit+ is a boolean indicating whether or not the map was implicitly
42      # started.
43      # +style+ is an integer indicating the mapping style.
44      #
45      # == See Also
46      # See also Psych::Handler#start_mapping
47      def initialize anchor = nil, tag = nil, implicit = true, style = BLOCK
48        super()
49        @anchor   = anchor
50        @tag      = tag
51        @implicit = implicit
52        @style    = style
53      end
54    end
55  end
56end
57