Class: Bandwidth::Bxml::Verb

Inherits:
Object
  • Object
show all
Defined in:
lib/bandwidth-sdk/models/bxml/verb.rb

Instance Method Summary collapse

Constructor Details

#initialize(tag, content = nil, attributes = {}) ⇒ Verb

Initializer



10
11
12
13
14
# File 'lib/bandwidth-sdk/models/bxml/verb.rb', line 10

def initialize(tag, content = nil, attributes = {})
  @tag = tag
  @content = content
  @attributes = attributes
end

Instance Method Details

#generate_xmlNode

Generate an XML element for the verb



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/bandwidth-sdk/models/bxml/verb.rb', line 24

def generate_xml
  root = Ox::Element.new(@tag)
  if @content
    root << @content
  end

  if !@attributes.empty? && !@attribute_map.nil?
    @attributes.each do |key, value|
      if @attribute_map.include? key.to_sym
        root[@attribute_map[key.to_sym]] = value
      else
        raise NoMethodError.new("attribute '#{key}' is not a valid attribute for this verb")
      end
    end
  end

  root
end

#set_attributes(attributes) ⇒ Object

Set XML attributes for the verb



18
19
20
# File 'lib/bandwidth-sdk/models/bxml/verb.rb', line 18

def set_attributes(attributes)
  @attributes = attributes
end

#to_bxmlString

Return BXML representaion of this element



45
46
47
# File 'lib/bandwidth-sdk/models/bxml/verb.rb', line 45

def to_bxml
  Ox.dump(generate_xml)
end