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