------ art_66542_368037.1172765944077 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 3/1/07, Louis J Scoras <louis.j.scoras / gmail.com> wrote: > > On 2/28/07, Samantha <rubygeekgirl / gmail.com> wrote: > > After taking several suggestions, I've come up with 91 lines of code > > (including blank lines because I like organizing things). > > > I'll post all 91 lines (including lines intentionally left blank), and > > explain what I'm having go wrong... I'm just not getting it, but maybe I > > don't quite understand certain things... (probably, not maybe ;) (And > > please excuse the rude prompts - I'm not really this rude, nor would I > write > > such a rude program for deployment into the world.) > > Samantha; > > Cool script. I like the prompts ;) I didn't write the prompt formula on my own, but I did write the sarcasm. :) One cool thing about ruby is that if you put key/value pairs at the > end of a method call they all get mashed together into a hash. You > can use that to help with readability. For example, many times in the > code you check a boolean condition and then write out a message. You > could try something like this: > > def verify_info(ok, hash) > if ok > puts hash[:next] > else > puts hash[:fail] > exit 1 > end > end > > Now the messages can be passed in like so: > > verify_info correct, > :next "Good, now moving on, let's get a little information > about your skills.", > :fail "Please come back when you have some goals." > > Or even get rid of the "correct" variable: > > verify_info boolean_prompt("Is this correct?"), > :next "Great, let's move onto your experience.", > :fail "Please come back when you know what you can do with > yourself. :)" > > In this case it doesn't afford you too much, but it does get rid of > the repeated pattern. Say you wanted to change the exit code. Now > you'd only need to edit it in one place. -- > Lou. > > So, what you're doing here is basically iterating through the hash and if it gets an ok, it goes to the next value to confirm, and otherwise, it fails? -- Samantha http://www.babygeek.org/ "Beware when the great God lets loose a thinker on this planet. Then all things are at risk." --Ralph Waldo Emerson ------ art_66542_368037.1172765944077--