title: Elegant command-parsing in an OOP-based text game
body: <p>I'm playing with writing a MUD/text adventure (please don't laugh) in Ruby.  Can anyone give me any pointers towards   an elegant, oop-based solution to parsing input text?  </p>
  
  <p>We're talking about nothing more complex than "put wand on table", here.  But everything needs to be soft; I want to extend the command set painlessly, later.  </p>
  
  <p>My current thoughts, slightly simplified:  </p>
  
  <ol>
  <li><p>Each item class (box, table, room, player) knows how to recognise a command that  'belongs' to it.</p></li>
  <li><p>The game class understands a sort of a domain-specific language involving actions such as "move object X inside object Y", "show description of object X", etc.  </p></li>
  <li><p>The game class asks each item in the room if it recognises the input command.  First to say yes wins.  </p></li>
  <li><p>It then passes control to a method in the item class that handles the command.  This method rephrases the command in the DSL, passes it back to the game object to make it happen.</p></li>
  </ol>
  
  <p>There must be well-worn, elegant ways of doing this stuff.  Can't seem to google anything, though.</p>