Class: Telapi::InboundXml
- Inherits:
-
Object
- Object
- Telapi::InboundXml
- Defined in:
- lib/telapi/inbound_xml.rb
Overview
Wraps TelAPI InboundXML functionality See www.telapi.com/docs/api/inboundxml/voice/introduction/
Instance Method Summary collapse
-
#initialize(&block) ⇒ InboundXml
constructor
Internally Nokogiri builder is being used to construct responses.
-
#response ⇒ Object
Returns xml.
Constructor Details
#initialize(&block) ⇒ InboundXml
Internally Nokogiri builder is being used to construct responses. See nokogiri.org/Nokogiri/XML/Builder.html
Pass in a block of options:
Telapi::InboundXml.new do
Say('Hello.', :loop => 3, :voice => 'man')
Say('Hello, my name is Jane.', :voice => 'woman')
Say('Now I will not stop talking.', :loop => 0)
end
Then calling #response produces the following output:
<Response>
<Say loop='3' voice='man'>Hello.</Say>
<Say voice='woman'>Hello, my name is Jane.</Say>
<Say loop='0'>Now I will not stop talking.</Say>
</Response>
26 27 28 29 |
# File 'lib/telapi/inbound_xml.rb', line 26 def initialize(&block) @xml = Nokogiri::XML::Builder.new @xml.Response &block end |
Instance Method Details
#response ⇒ Object
Returns xml
32 33 34 |
# File 'lib/telapi/inbound_xml.rb', line 32 def response @xml.to_xml end |