We go from an 'choose your own adventure' style to an automatic solver. And let's make some comments, show them an example of what we're doing and why. Always like to link to the definition of the type I'm working with, makes it a lot easier.
What kind of game doesn't congratulate you when you win?
This time, since it really goes inside that loop, I built it as a method from the beginning. Most of the implementation is the same as extract_href_from_xml. Sweet.
Doing this kind of dispatch feels ugly, but since the end goal is automated maze solving, I'm doing it anyway. Also, exit revealed something quite interesting. Can't name a variable 'exit', or else it quits Ruby. hahahaha! Oh, and you can't actually exit yet. Guess what I'm doing next...
Since these are the exact same, I did them all at the same time too. Now we print out which directions we can go in in the current room. You gotta hit control-c to break out, and you don't go anywhere. Whatever.
My Ruby style tends to be of the 'zillions of tiny methods' variety. So I wrap up _everything_ as methods, even if I'll only use them once, for clarity. This time I did two at once, because I'm impatient and one of them is only two lines. I got lucky... Developing software is all about discipline. You don't _have_ to follow best practices, but it's always those times that come back to bite you in the end.
First thing we need to do is grab the @start link. We'll use nokogiri to parse that out. Pretty simple.
Now that I have that working, I want to make a method that I can use. I take these steps really slow, _especially_ since I'm being bad and doing this without tests. It's just exploratory programming... Everyone says that in their first few commits, anyway.
First off, I wanted to figure out how the hell to use Net::HTTP. It never fails, I always forget. I did a google search for 'request headers net::http ruby' and came up with the documentation, which had an example I modified to get this. If you run it, you can see the initial maze XML come back. Awesome.
I often like to start out a project with a .gitignore and a .rvmrc. Documenting which Ruby you're using is a good start, and I hate accidentally adding vim's swapfiles into my repos.