Class: Julius::Prompt
- Inherits:
-
Object
- Object
- Julius::Prompt
- Defined in:
- lib/julius/prompt.rb
Defined Under Namespace
Classes: NoCommandError
Instance Method Summary collapse
-
#initialize(socket) ⇒ Prompt
constructor
A new instance of Prompt.
- #method_missing(name, *args) ⇒ Object
Constructor Details
#initialize(socket) ⇒ Prompt
Returns a new instance of Prompt.
5 6 7 |
# File 'lib/julius/prompt.rb', line 5 def initialize(socket) @socket = socket end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/julius/prompt.rb', line 9 def method_missing(name, *args) command = eval("Command::#{name.capitalize}").new(*args) @socket.puts(command.to_s) rescue NameError raise NoCommandError, "the command '#{name}' is not supported." end |