class StyledYAML::TreeBuilder

Custom tree builder class to recognize scalars tagged with ‘yaml_style`

Attributes

next_sequence_or_mapping_style[W]

Public Class Methods

new(*args) click to toggle source
Calls superclass method
# File lib/locomotive/wagon/tools/styled_yaml.rb, line 56
def initialize(*args)
  super
  @next_sequence_or_mapping_style = nil
end

Public Instance Methods

next_sequence_or_mapping_style(default_style) click to toggle source
# File lib/locomotive/wagon/tools/styled_yaml.rb, line 61
def next_sequence_or_mapping_style default_style
  style = @next_sequence_or_mapping_style || default_style
  @next_sequence_or_mapping_style = nil
  style
end
scalar(value, anchor, tag, plain, quoted, style) click to toggle source
Calls superclass method
# File lib/locomotive/wagon/tools/styled_yaml.rb, line 67
def scalar value, anchor, tag, plain, quoted, style
  if style_any?(style) and value.respond_to?(:yaml_style) and style = value.yaml_style
    if style_literal? style
      plain = false
      quoted = true
    end
  end
  super
end
style_any?(style) click to toggle source
# File lib/locomotive/wagon/tools/styled_yaml.rb, line 77
def style_any?(style) Psych::Nodes::Scalar::ANY == style end
style_literal?(style) click to toggle source
# File lib/locomotive/wagon/tools/styled_yaml.rb, line 79
def style_literal?(style) Psych::Nodes::Scalar::LITERAL == style end