Class: Bandwidth::Bxml::Root
- Inherits:
-
Object
- Object
- Bandwidth::Bxml::Root
- Defined in:
- lib/bandwidth-sdk/models/bxml/root.rb
Instance Method Summary collapse
-
#add_verbs(nested_verbs) ⇒ Object
Add a verb or verbs to the nested verbs array.
-
#generate_xml ⇒ Document
Generate an XML element for the BXML response.
-
#initialize(tag, nested_verbs = []) ⇒ Root
constructor
Initializer.
-
#to_bxml ⇒ String
Return BXML representaion of this response.
Constructor Details
#initialize(tag, nested_verbs = []) ⇒ Root
Initializer
12 13 14 15 |
# File 'lib/bandwidth-sdk/models/bxml/root.rb', line 12 def initialize(tag, nested_verbs = []) @tag = tag @nested_verbs = Array(nested_verbs) end |
Instance Method Details
#add_verbs(nested_verbs) ⇒ Object
Add a verb or verbs to the nested verbs array
35 36 37 |
# File 'lib/bandwidth-sdk/models/bxml/root.rb', line 35 def add_verbs(nested_verbs) @nested_verbs.push(*nested_verbs) end |
#generate_xml ⇒ Document
Generate an XML element for the BXML response
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/bandwidth-sdk/models/bxml/root.rb', line 19 def generate_xml xml = Ox::Document.new instruct = Ox::Instruct.new(:xml) instruct[:version] = '1.0' instruct[:encoding] = 'UTF-8' xml << instruct root = Ox::Element.new(@tag) @nested_verbs.each do |verb| root << verb.generate_xml end xml << root xml end |
#to_bxml ⇒ String
Return BXML representaion of this response
41 42 43 44 |
# File 'lib/bandwidth-sdk/models/bxml/root.rb', line 41 def to_bxml bxml = Ox.dump(generate_xml) bxml.gsub(SPEAK_SENTENCE_REGEX) { |text| text.gsub(SSML_REGEX, '<\1>') } end |