Class: Aws::Xml::DocBuilder Private

Inherits:
Object
  • Object
show all
Defined in:
lib/aws-sdk-core/xml/doc_builder.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ DocBuilder

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of DocBuilder

Options Hash (options):

  • :target (#<<) — default: ''
  • :pad (String) — default: ''
  • :indent (String) — default: ''


8
9
10
11
12
13
# File 'lib/aws-sdk-core/xml/doc_builder.rb', line 8

def initialize(options = {})
  @target = options[:target] || ''
  @indent = options[:indent] || ''
  @pad = options[:pad] || ''
  @end_of_line = @indent == '' ? '' : "\n"
end

Instance Attribute Details

#targetObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



15
16
17
# File 'lib/aws-sdk-core/xml/doc_builder.rb', line 15

def target
  @target
end

Instance Method Details

#node(name, attributes = {}) ⇒ void #node(name, value, attributes = {}) ⇒ void #node(name, attributes = {}, &block) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Overloads:

  • #node(name, attributes = {}) ⇒ void

    Adds a self closing element without any content.

  • #node(name, value, attributes = {}) ⇒ void

    Adds an element that opens and closes on the same line with simple text content.

  • #node(name, attributes = {}, &block) ⇒ void

    Adds a wrapping element. Calling #node from inside the yielded block creates nested elements.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/aws-sdk-core/xml/doc_builder.rb', line 30

def node(name, *args, &block)
  attrs = args.last.is_a?(Hash) ? args.pop : {}
  if block_given?
    @target << open_el(name, attrs)
    @target << @end_of_line
    increase_pad { yield }
    @target << @pad
    @target << close_el(name)
  elsif args.empty?
    @target << empty_element(name, attrs)
  else
    @target << inline_element(name, args.first, attrs)
  end
end