Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @@commands = {
- :showhelp => :show_help,
- :help => :help,
- :shuffle => :shuffle,
- :new => :new_cmd,
- :quit => :quit,
- :unknown => :unknown
- }
- def execute (cmd)
- #save last entered command
- @last_command = cmd
- # check in the dictionary
- cmd = cmd.to_sym
- opcode = ( @@commands.has_key?(cmd) ? @@commands[cmd] : :unknown )
- puts opcode.inspect
- # call method
- self.send(opcode)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement