Class: AlbaHabla::Commands
- Inherits:
-
Object
- Object
- AlbaHabla::Commands
- Defined in:
- lib/alba_habla/commands.rb
Overview
Main class used to process commands
Constant Summary collapse
- DEFAULT_VOICES =
{ 'say' => 'Fiona', 'espeak' => 'en-westindies', }.freeze
Instance Attribute Summary collapse
-
#voice ⇒ Object
readonly
Returns the value of attribute voice.
Instance Method Summary collapse
-
#initialize(book_path, voice = nil) ⇒ Commands
constructor
A new instance of Commands.
- #process_command(command) ⇒ Object
Constructor Details
#initialize(book_path, voice = nil) ⇒ Commands
Returns a new instance of Commands.
11 12 13 14 |
# File 'lib/alba_habla/commands.rb', line 11 def initialize(book_path, voice = nil) @voice = voice || DEFAULT_VOICES[executable] @book_path = book_path end |
Instance Attribute Details
#voice ⇒ Object (readonly)
Returns the value of attribute voice.
4 5 6 |
# File 'lib/alba_habla/commands.rb', line 4 def voice @voice end |
Instance Method Details
#process_command(command) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/alba_habla/commands.rb', line 16 def process_command(command) subcommand = command.split(' ').first if available_subcommands.include? subcommand send(subcommand, command.split(' ')[1..-1].join(' ')) else talk(command) end end |