Class Request::TtsMessage
In: lib/violet/request.rb
Parent: Base::Event
Event Action TtsMessage SetEarsPosition EventCollection Enumerable Query GET_EARS_POSITION Base Request dot/f_8.png

Methods

new   to_url  

Constants

MIN_SPEED = 1
MAX_SPEED = 32000
MIN_PITCH = 1
MAX_PITCH = 32000

Public Class methods

[Source]

     # File lib/violet/request.rb, line 140
140:     def initialize h
141:       raise ArgumentError.new('no text given') unless h[:tts]
142:       @h = h.dup
143: 
144:       [:speed,:pitch].each do |p|
145:         min = Helpers.constantize("#{self.class}::MIN_#{p.to_s.upcase}")
146:         max = Helpers.constantize("#{self.class}::MAX_#{p.to_s.upcase}")
147: 
148:         unless @h[p].to_i.between?(min,max)
149:           raise ArgumentError.new("#{p} values must be between #{min} and #{max}")
150:         else
151:           @h[p] = @h[p].to_i
152:         end if @h[p]
153:       end
154: 
155:       @h[:tts] = CGI.escape @h[:tts]
156:     end

Public Instance methods

[Source]

     # File lib/violet/request.rb, line 158
158:     def to_url
159:       for p in [:tts,:voice,:speed,:pitch] do
160:         (url ||= Array.new) << "#{p}=#{@h[p]}" if @h[p]
161:       end
162: 
163:       url.join('&')
164:     end

[Validate]