Advertisement
Guest User

Untitled

a guest
Jul 28th, 2012
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.42 KB | None | 0 0
  1.     @@commands = {
  2.         :showhelp => :show_help,
  3.         :help => :help,
  4.         :shuffle => :shuffle,
  5.         :new => :new_cmd,
  6.         :quit => :quit,
  7.         :unknown => :unknown
  8.     }
  9.  
  10.     def execute (cmd)
  11.  
  12.         #save last entered command
  13.         @last_command = cmd
  14.  
  15.         # check in the dictionary
  16.         cmd = cmd.to_sym
  17.         opcode = ( @@commands.has_key?(cmd) ? @@commands[cmd] : :unknown )
  18.         puts opcode.inspect
  19.  
  20.         # call method
  21.         self.send(opcode)
  22.  
  23.     end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement