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, #end_column, #end_line, #start_column, #start_line

Instance Method Summary collapse

Methods inherited from Node

#alias?, #document?, #each, #mapping?, #sequence?, #stream?, #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 indicating the string style

See Also

See also Psych::Handler#scalar



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

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)



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

def anchor
  @anchor
end

#plainObject

Is this a plain scalar?



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

def plain
  @plain
end

#quotedObject

Is this scalar quoted?



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

def quoted
  @quoted
end

#styleObject

The style of this scalar



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

def style
  @style
end

#tagObject

The tag value (if there is one)



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

def tag
  @tag
end

#valueObject

The scalar value



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

def value
  @value
end

Instance Method Details

#scalar?Boolean

Returns:

  • (Boolean)


67
# File 'lib/psych/nodes/scalar.rb', line 67

def scalar?; true; end