Class: Psych::Nodes::Scalar

Inherits:
Node show all
Defined in:
lib/psych/nodes/scalar.rb

Overview

This class represents a YAML Scalar.

This node type is a terminal node and should not have any children.

Constant Summary collapse

ANY =

Any style scalar, the emitter chooses

0
PLAIN =

Plain scalar style

1
SINGLE_QUOTED =

Single quoted style

2
DOUBLE_QUOTED =

Double quoted style

3
LITERAL =

Literal style

4
FOLDED =

Folded style

5

Instance Attribute Summary collapse

Attributes inherited from Node

#children

Instance Method Summary collapse

Methods inherited from Node

#each, #to_ruby, #yaml

Constructor Details

#initialize(value, anchor = nil, tag = nil, plain = true, quoted = false, style = ANY) ⇒ Scalar

Create a new Psych::Nodes::Scalar object.

value is the string value of the scalar anchor is an associated anchor or nil tag is an associated tag or nil plain is a boolean value quoted is a boolean value style is an integer idicating the string style

See Also

See also Psych::Handler#scalar



57
58
59
60
61
62
63
64
# File 'lib/psych/nodes/scalar.rb', line 57

def initialize value, anchor = nil, tag = nil, plain = true, quoted = false, style = ANY
  @value  = value
  @anchor = anchor
  @tag    = tag
  @plain  = plain
  @quoted = quoted
  @style  = style
end

Instance Attribute Details

#anchorObject

The anchor value (if there is one)



30
31
32
# File 'lib/psych/nodes/scalar.rb', line 30

def anchor
  @anchor
end

#plainObject

Is this a plain scalar?



36
37
38
# File 'lib/psych/nodes/scalar.rb', line 36

def plain
  @plain
end

#quotedObject

Is this scalar quoted?



39
40
41
# File 'lib/psych/nodes/scalar.rb', line 39

def quoted
  @quoted
end

#styleObject

The style of this scalar



42
43
44
# File 'lib/psych/nodes/scalar.rb', line 42

def style
  @style
end

#tagObject

The tag value (if there is one)



33
34
35
# File 'lib/psych/nodes/scalar.rb', line 33

def tag
  @tag
end

#valueObject

The scalar value



27
28
29
# File 'lib/psych/nodes/scalar.rb', line 27

def value
  @value
end