lib/talks.rb in talks-0.0.2 vs lib/talks.rb in talks-0.0.3

- old
+ new

@@ -1,44 +1,48 @@ module Talks class << self VOICES = %w( - Agnes Albert Alex Bad Bahh Bells Boing Bruce Bubbles Cellos - Deranged Fred Good Hysterical Junior Kathy Pipe Princess Ralph - Trinoids Vicki Victoria Whisper Zarvox + agnes albert alex bad bahh bells boing bruce bubbles cellos + deranged fred good hysterical junior kathy pipe princess ralph + trinoids vicki victoria whisper zarvox ) PREFS = { - info: 'Bruce', - warn: 'Whisper', - success: 'Fred', - error: 'Trinoids' + info: 'vicki', + warn: 'whisper', + success: 'vicki', + error: 'bad' } def voice @voice ||= :info end def voice=(voice = :info) @voice ||= voice end - def say(message, type = voice, options = {}) - type = type.to_sym + def voices + VOICES + end + + def say(message, options = {}) + type = options[:type].to_sym if options[:type] say_voice = \ - if options[:voice] and VOICES.include?(options[:voice].to_downcase) + if options[:voice] and VOICES.include?(options[:voice].to_s) options[:voice] elsif PREFS.keys.include? type PREFS[type] else PREFS[voice] end `say -v #{say_voice} #{message}` end PREFS.keys.each do |type| - define_method type do |message, options = {}| - say(message, type, options) + define_method type do |message, options = {type: type}| + say(message, options) end end end end