Hi all,
I’ve spent a few minutes this morning working on some code for that
Resume
Builder that was suggested to me on this list a few weeks ago…
I have written some horribly ugly procedural code and wanted to get some
input as to how I can make it more Ruby like.
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.
Anyway, I’m stepping out on a limb here and putting out some stuff…
I’ve
ran the code and it works and does what I want… I just know that it’s
horribly tedious.
Thanks!
(PS - Don’t make fun of me too harshly )
#ResumeBuilder.rb
puts(“Welcome to ResumeBuilder v.1”)
puts("Please enter your first name: ")
first_name = gets.chomp.capitalize!
puts("Please enter your last name: ")
last_name = gets.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
if correct.downcase == “yes”: puts("Excellent, " + first_name + “!”)
else puts("Please enter your first name: ")
first_name = gets.chomp.capitalize!
puts("Please enter your last name: ")
last_name = gets.chomp.capitalize!
puts("You have entered " + full_name + “! Is this correct?
(yes/no)”)
correct = gets.chomp
if correct.downcase == “yes”: puts("Great, let’s get started, " +
first_name + “!”)
else puts(“Please come back when you know your name.”)
end
end
puts("Please enter your street number: ")
street_number = gets.chomp!
puts("Please enter your street name: ")
street_name = gets.chomp.capitalize!
puts("Please enter your city name: ")
city_name = gets.chomp.capitalize!
puts("Please enter your state: ")
state_name = gets.chomp.upcase!
puts(“Please enter your zip code: “)
zip_code = gets.chomp!
puts(“You have told me that you live at:\n” + street_number + " " +
street_name +”\n” + city_name + ", " + state_name + " " + zip_code +
“\nIs
this correct? (yes/no)”)
correct = gets.chomp
if correct.downcase == “yes”: puts(“Great, let’s continue!”)
else puts("Please enter your street number: ")
street_number = gets.chomp!
puts("Please enter your street name: ")
street_name = gets.chomp.capitalize!
puts("Please enter your city name: ")
city_name = gets.chomp.capitalize!
puts("Please enter your state: ")
state_name = gets.chomp.upcase!
puts(“Please enter your zip code: “)
zip_code = gets.chomp!
puts(“You have told me that you live at:\n” + street_number + " " +
street_name +”\n” + city_name + ", " + state_name + " " + zip_code +
“\nIs
this correct? (yes/no)”)
if correct.downcase == “yes”: puts(“Great, let’s continue!”)
else puts(“Please come back when you know where you live.”)
end
end
–
Samantha
“Beware when the great God lets loose a thinker on this planet. Then all
things are at risk.”
–Ralph Waldo Emerson