Class: Bandwidth::Voice::Response

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

Instance Method Summary collapse

Constructor Details

#initialize(verbs = nil) ⇒ Response

Initializer

Parameters:

  • verbs (Array) (defaults to: nil)

    optional list of verbs to include into response



15
16
17
# File 'lib/bandwidth/voice_lib/bxml/bxml.rb', line 15

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

Instance Method Details

#<<(verb) ⇒ Object

Add a verb to this response



35
36
37
# File 'lib/bandwidth/voice_lib/bxml/bxml.rb', line 35

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

#push(*verbs) ⇒ Object

Add one or more verbs to this response



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

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

#to_bxmlObject

Return BXML representaion of this response



20
21
22
23
24
25
26
27
# File 'lib/bandwidth/voice_lib/bxml/bxml.rb', line 20

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