Class: Bandwidth::Bxml::Root
- Inherits:
-
Object
- Object
- Bandwidth::Bxml::Root
- Extended by:
- Gem::Deprecate
- Defined in:
- lib/bandwidth-sdk/models/bxml/root.rb
Instance Method Summary collapse
- #add_verb(nested_verbs) ⇒ Object
-
#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_verb(nested_verbs) ⇒ Object
40 41 42 |
# File 'lib/bandwidth-sdk/models/bxml/root.rb', line 40 def add_verb(nested_verbs) add_verbs(nested_verbs) end |
#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
47 48 49 50 |
# File 'lib/bandwidth-sdk/models/bxml/root.rb', line 47 def to_bxml bxml = Ox.dump(generate_xml) bxml.gsub(SPEAK_SENTENCE_REGEX) { |text| text.gsub(SSML_REGEX, '<\1>') } end |