Class: Fluent::Config::YamlParser::SectionBuilder

Inherits:
Struct
  • Object
show all
Defined in:
lib/fluent/config/yaml_parser/section_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#argObject

Returns the value of attribute arg

Returns:

  • (Object)

    the current value of arg



20
21
22
# File 'lib/fluent/config/yaml_parser/section_builder.rb', line 20

def arg
  @arg
end

#bodyObject

Returns the value of attribute body

Returns:

  • (Object)

    the current value of body



20
21
22
# File 'lib/fluent/config/yaml_parser/section_builder.rb', line 20

def body
  @body
end

#indent_sizeObject

Returns the value of attribute indent_size

Returns:

  • (Object)

    the current value of indent_size



20
21
22
# File 'lib/fluent/config/yaml_parser/section_builder.rb', line 20

def indent_size
  @indent_size
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



20
21
22
# File 'lib/fluent/config/yaml_parser/section_builder.rb', line 20

def name
  @name
end

Instance Method Details

#to_elementObject



31
32
33
34
35
36
37
# File 'lib/fluent/config/yaml_parser/section_builder.rb', line 31

def to_element
  elem = body.to_element
  elem.name = name
  elem.arg = arg.to_s if arg
  elem.v1_config = true
  elem
end

#to_sObject



21
22
23
24
25
26
27
28
29
# File 'lib/fluent/config/yaml_parser/section_builder.rb', line 21

def to_s
  indent = ' ' * indent_size

  if arg && !arg.to_s.empty?
    "#{indent}<#{name} #{arg}>\n#{body}\n#{indent}</#{name}>"
  else
    "#{indent}<#{name}>\n#{body}\n#{indent}</#{name}>"
  end
end