Class: Julius::Prompt

Inherits:
Object
  • Object
show all
Defined in:
lib/julius/prompt.rb

Defined Under Namespace

Classes: NoCommandError

Instance Method Summary collapse

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