Class: Talks::Configuration
- Inherits:
-
Object
- Object
- Talks::Configuration
- Defined in:
- lib/talks/configuration.rb
Constant Summary collapse
- DEFAULT_VOICES =
{ :say => { :info => 'vicki', :warn => 'whisper', :success => 'vicki', :error => 'bad' }, :espeak => { :info => 'en+f3', :warn => 'en+m1', :success => 'en+f3', :error => 'en+m3' } }
- DEFAULT_MESSAGES =
{ :info => 'Information note', :warn => 'Warning', :success => 'Success', :error => 'Error' }
Instance Attribute Summary collapse
-
#default_voice ⇒ Object
Returns the value of attribute default_voice.
-
#detach ⇒ Object
Returns the value of attribute detach.
-
#engine ⇒ Object
Returns the value of attribute engine.
-
#messages ⇒ Object
Returns the value of attribute messages.
-
#notifier ⇒ Object
Returns the value of attribute notifier.
-
#notifier_options ⇒ Object
Returns the value of attribute notifier_options.
-
#notify_by_default ⇒ Object
Returns the value of attribute notify_by_default.
-
#options ⇒ Object
Returns the value of attribute options.
-
#voices ⇒ Object
Returns the value of attribute voices.
Instance Method Summary collapse
- #default_message_for(command_name, position = :after) ⇒ Object
-
#initialize(opts) ⇒ Configuration
constructor
A new instance of Configuration.
- #message(type) ⇒ Object
- #message_for(command_name, position = :after, kind = 'message') ⇒ Object
- #notifier_for(command_name) ⇒ Object
- #notify_message_for(command_name, position = :after) ⇒ Object
- #talk(type) ⇒ Object
- #voice(type) ⇒ Object
- #voice_for(command_name) ⇒ Object
Constructor Details
#initialize(opts) ⇒ Configuration
Returns a new instance of Configuration.
31 32 33 34 35 |
# File 'lib/talks/configuration.rb', line 31 def initialize(opts) @options = symbolize_hash_keys(opts) end |
Instance Attribute Details
#default_voice ⇒ Object
Returns the value of attribute default_voice.
28 29 30 |
# File 'lib/talks/configuration.rb', line 28 def default_voice @default_voice end |
#detach ⇒ Object
Returns the value of attribute detach.
28 29 30 |
# File 'lib/talks/configuration.rb', line 28 def detach @detach end |
#engine ⇒ Object
Returns the value of attribute engine.
28 29 30 |
# File 'lib/talks/configuration.rb', line 28 def engine @engine end |
#messages ⇒ Object
Returns the value of attribute messages.
28 29 30 |
# File 'lib/talks/configuration.rb', line 28 def @messages end |
#notifier ⇒ Object
Returns the value of attribute notifier.
28 29 30 |
# File 'lib/talks/configuration.rb', line 28 def notifier @notifier end |
#notifier_options ⇒ Object
Returns the value of attribute notifier_options.
28 29 30 |
# File 'lib/talks/configuration.rb', line 28 def @notifier_options end |
#notify_by_default ⇒ Object
Returns the value of attribute notify_by_default.
28 29 30 |
# File 'lib/talks/configuration.rb', line 28 def notify_by_default @notify_by_default end |
#options ⇒ Object
Returns the value of attribute options.
28 29 30 |
# File 'lib/talks/configuration.rb', line 28 def @options end |
#voices ⇒ Object
Returns the value of attribute voices.
28 29 30 |
# File 'lib/talks/configuration.rb', line 28 def voices @voices end |
Instance Method Details
#default_message_for(command_name, position = :after) ⇒ Object
49 50 51 |
# File 'lib/talks/configuration.rb', line 49 def (command_name, position = :after) "#{command_name} task #{position == :before ? 'started' : 'ended'}" end |
#message(type) ⇒ Object
41 42 43 |
# File 'lib/talks/configuration.rb', line 41 def (type) [type] if .keys.include?(type) end |
#message_for(command_name, position = :after, kind = 'message') ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/talks/configuration.rb', line 53 def (command_name, position = :after, kind = 'message') command = command_name.to_sym = \ position == :before ? "before_#{kind}" : "after_#{kind}" [command][.to_sym] if [command] end |
#notifier_for(command_name) ⇒ Object
65 66 67 68 69 70 71 72 73 |
# File 'lib/talks/configuration.rb', line 65 def notifier_for(command_name) command = command_name.to_sym ([:notifier] != 'off') && ( ![command] || ([command] && ([command][:notifier] != 'off')) ) end |
#notify_message_for(command_name, position = :after) ⇒ Object
61 62 63 |
# File 'lib/talks/configuration.rb', line 61 def (command_name, position = :after) (command_name, position, 'notify') end |
#talk(type) ⇒ Object
45 46 47 |
# File 'lib/talks/configuration.rb', line 45 def talk(type) [(type), voice(type)] end |
#voice(type) ⇒ Object
37 38 39 |
# File 'lib/talks/configuration.rb', line 37 def voice(type) voices[type] if voices.keys.include?(type) end |
#voice_for(command_name) ⇒ Object
75 76 77 78 79 |
# File 'lib/talks/configuration.rb', line 75 def voice_for(command_name) command = command_name.to_sym [command] && [command][:voice] end |