On Fri, Dec 28, 2012 at 10:17 AM, Peter Hickman
<peterhickman386 / googlemail.com> wrote:
> Well you could just place all the code between
>
> class Dungeon
>  .. and ...
> end
>
> into a file called dungeon.rb and create a new file called play.rb
>
> -- play.rb
> #!/usr/bin/env ruby
>
> require 'dungeon'
>
> my_dungeon = Dungeon.new("Fred Bloggs")
> my_dungeon.add_room(:largecave, "Large Cave", "a large cavernous cave", {
> :west => :smallcave, :east => :kitchen })
> my_dungeon.add_room(:smallcave, "Small Cave", "a small, claustrophobic
> cave", { :east => :largecave })
> my_dungeon.add_room(:kitchen, "Kitchen", "a small kitchen", {:west =>
> :largecave})
>
> my_dungeon.start(:largecave)
> while true
>   print "go where? "
>   go_to = STDIN.gets.chomp
>   my_dungeon.go(go_to)
> end
>
> now all you need to run it is
>
> $ ruby play.rb
>
> It will load the Dungeon class from dungeon.rb and run it (providing it is
> in the same directory as play.rb).
>

As was recommended to me previously, I'd suggest looking at GLI and
Methadone to create command line applications, which it looks like
your adventure game is. (RIght on! Good start!)

Likewise, the RSpec book, which is quite a bit about test/behaviour
driven development, uses a game application as a case study. Working
your way through that will be of double benefit.