Class: Bandwidth::Voice::Bxml

Inherits:
Object
  • Object
show all
Defined in:
lib/bandwidth/voice_lib/bxml/bxml.rb

Instance Method Summary collapse

Constructor Details

#initialize(verbs = nil) ⇒ Bxml

Initializer

Parameters:

  • verbs (Array) (defaults to: nil)

    optional list of verbs to include in the bxml tag



11
12
13
# File 'lib/bandwidth/voice_lib/bxml/bxml.rb', line 11

def initialize(verbs = nil)
  @verbs = verbs || []
end

Instance Method Details

#<<(verb) ⇒ Object

Add a verb to this response



31
32
33
# File 'lib/bandwidth/voice_lib/bxml/bxml.rb', line 31

def <<(verb)
  @verbs << verb
end

#push(*verbs) ⇒ Object

Add one or more verbs to this response



26
27
28
# File 'lib/bandwidth/voice_lib/bxml/bxml.rb', line 26

def push(*verbs)
  @verbs.push(*verbs)
end

#to_bxmlObject

Return BXML representaion of this response



16
17
18
19
20
21
22
23
# File 'lib/bandwidth/voice_lib/bxml/bxml.rb', line 16

def to_bxml()
  xml = Builder::XmlMarkup.new()
  xml.instruct!(:xml, :version=>'1.0', :encoding=>'UTF-8')
  xml.Bxml do
    @verbs.each {|verb| verb.to_bxml(xml)}
  end
  xml.target!().gsub(SPEAK_SENTENCE_REGEX){|s|s.gsub(SSML_REGEX, '<\1>')}
end