From: Raj Sahae Date: 2007-03-01T04:15:31+09:00 Subject: Re: Stepping out on a Limb - some very ugly code Samantha wrote: > My code is exceedingly redundant. The only "woohoo!" I have about it, is > that I didn't have to look anything up in reference to write it. Well, I'm new to ruby too, but the most obvious things I would do is loop the gets so that you don't write everything twice, and make a method to handle the gets so that you don't write that 10 times. As far as making it more "rubyish", I'm sure I would mess that up, but I guess, with that in mind, I would at least put it in a class, and I personally like using string interpolation, it's more readable for me. Raj #ResumeBuilder.rb class ResumeBuilder def initialize puts("Welcome to ResumeBuilder v.1") correct = "" until correct.downcase == "yes" @first_name = prompt_and_get("first name").chomp.capitalize @last_name = prompt_and_get("last name").chomp.capitalize @full_name = "#{@first_name} #{@last_name}" puts("You have entered #{@full_name} as your name. Is this correct? (yes/no)") correct = gets.chomp end correct = "" until correct.downcase == "yes" @street_number = prompt_and_get("street number").chomp @street_name = prompt_and_get("street name").chomp.capitalize @city_name = prompt_and_get("city name").chomp.capitalize @state_name = prompt_and_get("state").chomp.upcase @zip_code = prompt_and_get("zip code").chomp puts "You have told me that you live at: #{@street_number} #{@street_name} #{@city_name}, #{@state_name} #{@zip_code} Is this correct? (yes/no)" correct = gets.chomp end end def prompt_and_get(string) puts "Please enter your #{string}: " gets end end ResumeBuilder.new