Class: Bandwidth::Voice::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/bandwidth/voice_lib/bxml/response.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



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

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

Instance Method Details

#<<(verb) ⇒ Object

Add a verb to this response



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

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

#push(*verbs) ⇒ Object

Add one or more verbs to this response



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

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

#to_bxmlObject

Return BXML representaion of this response



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

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