class Motion::Speech::Utterance
Public Class Methods
new(speakable, options={})
click to toggle source
# File lib/motion/speech/utterance.rb, line 5 def initialize(speakable, options={}) self.message = speakable self.rate = options.fetch(:rate, 0.15) self.pitch = options.fetch(:pitch, 1.0) self.voice = options.fetch(:voice, nil) self.volume = options.fetch(:volume, 1.0) end
Public Instance Methods
setRate(multiplier)
click to toggle source
Calls superclass method
# File lib/motion/speech/utterance.rb, line 17 def setRate(multiplier) super rate_for_symbol_or_float(multiplier) end
Also aliased as: rate=
setSpeechString(speakable)
click to toggle source
Calls superclass method
# File lib/motion/speech/utterance.rb, line 13 def setSpeechString(speakable) super string_from_speakable(speakable) end
Also aliased as: message=
Private Instance Methods
rate_for_symbol_or_float(rate)
click to toggle source
# File lib/motion/speech/utterance.rb, line 37 def rate_for_symbol_or_float(rate) case rate when :maximum AVSpeechUtteranceMaximumSpeechRate when :minimum AVSpeechUtteranceMinimumSpeechRate when :default AVSpeechUtteranceDefaultSpeechRate when Fixnum, Float rate.to_f else raise ArgumentError, "invalid rate given: '#{rate}'" end end
string_from_speakable(speakable)
click to toggle source
# File lib/motion/speech/utterance.rb, line 29 def string_from_speakable(speakable) if speakable.respond_to?(:to_speakable) speakable.to_speakable else speakable end end