lib/adhearsion/call_controller/output/formatter.rb in adhearsion-2.4.0 vs lib/adhearsion/call_controller/output/formatter.rb in adhearsion-2.5.0
- old
+ new
@@ -6,10 +6,13 @@
class CallController
module Output
class Formatter
def ssml_for_collection(collection)
+ collection = collection.compact
+ raise NoDocError if collection.empty?
+
collection.inject RubySpeech::SSML.draw do |doc, argument|
doc + case argument
when Hash
ssml_for argument.delete(:value), argument
when RubySpeech::SSML::Speak
@@ -26,10 +29,12 @@
case output
when Date, Time, DateTime
:time
when Numeric, /^\d+$/
:numeric
+ when /^[\d\*\#]+$/
+ :characters
when /^\//, ->(string) { uri? string }
:audio
else
:text
end
@@ -43,11 +48,11 @@
#
# Generates SSML for the argument and options passed, using automatic detection
# Directly returns the argument if it is already an SSML document
#
- # @param [String, Hash, RubySpeech::SSML::Speak] the argument with options as accepted by the play_ methods, or an SSML document
+ # @param [String, Hash, RubySpeech::SSML::Speak] args the argument with options as accepted by the play_ methods, or an SSML document
# @return [RubySpeech::SSML::Speak] an SSML document
#
def ssml_for(*args)
return args[0] if args.size == 1 && args[0].is_a?(RubySpeech::SSML::Speak)
argument, options = args.flatten
@@ -87,10 +92,10 @@
RubySpeech::SSML.draw do
audio(:src => argument) { fallback }
end
end
- def ssml_for_characters(argument)
+ def ssml_for_characters(argument, options = {})
RubySpeech::SSML.draw do
say_as(interpret_as: 'characters') { string argument.to_s }
end
end
end