Class: Aws::Xml::DocBuilder Private

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

Overview

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.

API:

  • private

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: ''

API:

  • private



10
11
12
13
14
15
16
17
18
19
# File 'lib/aws-sdk-core/xml/doc_builder.rb', line 10

def initialize(options = {})
  @target = options[:target] || (
    # The String has to be mutable
    # because @target implements `<<` method.
    String.new
  )
  @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.

API:

  • private



21
22
23
# File 'lib/aws-sdk-core/xml/doc_builder.rb', line 21

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.

API:

  • private



36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/aws-sdk-core/xml/doc_builder.rb', line 36

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(&block)
    @target << @pad
    @target << close_el(name)
  elsif args.empty?
    @target << empty_element(name, attrs)
  else
    @target << inline_element(name, args.first, attrs)
  end
end