lib/adhearsion/call_controller/output.rb in adhearsion-2.0.0.alpha3 vs lib/adhearsion/call_controller/output.rb in adhearsion-2.0.0.beta1
- old
+ new
@@ -1,10 +1,10 @@
module Adhearsion
class CallController
module Output
def speak(text, options = {})
- play_ssml(text, options) || output(:text, text, options)
+ play_ssml(text, options) || output(:text, text.to_s, options)
end
#
# Plays the specified sound file names. This method will handle Time/DateTime objects (e.g. Time.now),
# Fixnums (e.g. 1000), Strings which are valid Fixnums (e.g "123"), and direct sound files. To specify how the Date/Time objects are said
@@ -108,22 +108,22 @@
def play_audio(*args)
argument, options = args.flatten
play_ssml ssml_for_audio(argument, options)
end
- def play_ssml(ssml, options = {})
+ def play_ssml(ssml, options = {}) # :nodoc:
if [RubySpeech::SSML::Speak, Nokogiri::XML::Document].include? ssml.class
output :ssml, ssml.to_s, options
end
end
- def output(type, content, options = {})
+ def output(type, content, options = {}) # :nodoc:
options.merge! type => content
execute_component_and_await_completion ::Punchblock::Component::Output.new(options)
end
- def output!(type, content, options = {})
+ def output!(type, content, options = {}) # :nodoc:
options.merge! type => content
execute_component_and_await_completion ::Punchblock::Component::Output.new(options)
end
#
@@ -168,42 +168,42 @@
end
end
result
end
- def detect_type(output)
+ def detect_type(output) # :nodoc:
result = nil
result = :time if [Date, Time, DateTime].include? output.class
result = :numeric if output.kind_of?(Numeric) || output =~ /^\d+$/
result = :audio if !result && (/\//.match(output.to_s) || URI::regexp(%w(http https)).match(output.to_s))
result ||= :text
end
- def play_ssml_for(*args)
+ def play_ssml_for(*args) # :nodoc:
play_ssml ssml_for(args)
end
#
# 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
# @return [RubySpeech::SSML::Speak] an SSML document
#
- def ssml_for(*args)
+ def ssml_for(*args) # :nodoc:
return args[0] if args.size == 1 && args[0].is_a?(RubySpeech::SSML::Speak)
argument, options = args.flatten
options ||= {}
type = detect_type argument
send "ssml_for_#{type}", argument, options
end
- def ssml_for_text(argument, options = {})
+ def ssml_for_text(argument, options = {}) # :nodoc:
RubySpeech::SSML.draw { argument }
end
- def ssml_for_time(argument, options = {})
+ def ssml_for_time(argument, options = {}) # :nodoc:
interpretation = case argument
when Date then 'date'
when Time then 'time'
end
@@ -215,16 +215,16 @@
RubySpeech::SSML.draw do
say_as(:interpret_as => interpretation, :format => format) { time_to_say }
end
end
- def ssml_for_numeric(argument, options = {})
+ def ssml_for_numeric(argument, options = {}) # :nodoc:
RubySpeech::SSML.draw do
say_as(:interpret_as => 'cardinal') { argument.to_s }
end
end
- def ssml_for_audio(argument, options = {})
+ def ssml_for_audio(argument, options = {}) # :nodoc:
fallback = (options || {}).delete :fallback
RubySpeech::SSML.draw do
audio(:src => argument) { fallback }
end
end