Sha256: ef076b045cbe43bdbf95a1bf0d0a459d96afcc34148d3f23cae9fa272e6e8b9b

Contents?: true

Size: 883 Bytes

Versions: 8

Compression:

Stored size: 883 Bytes

Contents

require 'builder'
Dir[File.dirname(__FILE__) + '/verbs/*'].each {|file|
  require_relative file
}

module Bandwidth 
  module Voice 
    class Bxml
      # Initializer
      # @param verbs [Array] optional list of verbs to include in the bxml tag
      def initialize(verbs = nil)
        @verbs = verbs || []
      end

      # Return BXML representaion of this response
      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

      # Add one or more verbs to this response
      def push(*verbs)
        @verbs.push(*verbs)
      end

      # Add a verb to this response
      def <<(verb)
        @verbs << verb
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
bandwidth-sdk-10.5.0 lib/bandwidth/voice_lib/bxml/bxml.rb
bandwidth-sdk-10.4.0 lib/bandwidth/voice_lib/bxml/bxml.rb
bandwidth-sdk-10.3.0 lib/bandwidth/voice_lib/bxml/bxml.rb
bandwidth-sdk-10.2.0 lib/bandwidth/voice_lib/bxml/bxml.rb
bandwidth-sdk-10.1.0 lib/bandwidth/voice_lib/bxml/bxml.rb
bandwidth-sdk-10.0.0 lib/bandwidth/voice_lib/bxml/bxml.rb
bandwidth-sdk-9.4.1 lib/bandwidth/voice_lib/bxml/bxml.rb
bandwidth-sdk-9.4.0 lib/bandwidth/voice_lib/bxml/bxml.rb