It is currently 3:48pm EST.
At approximately 1:15pm EST today, I started teaching myself Ruby.
Two and a half hours later, I submitted a Mad Lib program to the Week 5 challenge of the 52 Weeks of Code thing we got going on. Is it ugly? Yup. Is it rudimentary? You know it. Is the formatting absolute crap? Indeed it is. Does it work? You're damn right it does! w00t! w00t!
Here she be - my first actual program in Ruby:
At approximately 1:15pm EST today, I started teaching myself Ruby.
Two and a half hours later, I submitted a Mad Lib program to the Week 5 challenge of the 52 Weeks of Code thing we got going on. Is it ugly? Yup. Is it rudimentary? You know it. Is the formatting absolute crap? Indeed it is. Does it work? You're damn right it does! w00t! w00t!
Here she be - my first actual program in Ruby:
puts "\n\nThe Bedtime Story Mad Lib\n\nby B9\n\n" puts "Name 1 location: " print "1. " loc=gets() puts "\n\nEnter 5 adjectives: " print "1. " adj1=gets() print "\n2. " adj2=gets() print "\n3. " adj3=gets() print "\n4. " adj4=gets() print "\n5. " adj5=gets() puts "\n\nName 2 female celebrities: " print "1. " femceb1=gets() print "\n2. " femceb2=gets() puts "\n\nName 1 male celebrity: " print "1. " malceb=gets() puts "\n\nEnter 2 plural nouns: " print "1. " pln1=gets() print "\n2. " pln2=gets() puts "\n\nName 4 body parts: " print "1. " body1=gets() print "\n2. " body2=gets() print "\n3. " body3=gets() print "\n4. " body4=gets() puts "\n\nSelect 2 nouns: " print "1. " noun1=gets() print "\n2. " noun2=gets() puts "\n\nChoose 2 numbers: " print "1. " numb1=gets() print "\n2. " numb2=gets() puts "\n\nName 1 famous building: " print "1. " build=gets() puts "\n\nChoose 1 animal: " print "1. " animal=gets() puts "\n\nEnter 1 verb: " print "1. " verb=gets() puts "\n\nChoose 1 past-tense verb: " print "1. " ptverb=gets() puts "\n\nYour Bedtime Story Mad Lib\n\n Once upon a time in a place called #{loc} there was a/an #{adj1} Princess named #{femceb1}. Her kingdom was huge but her #{pln1} were bigger. She was beautiful from her #{body1} to her #{body2}.\n\n One day, she saw a/an #{adj2} prince named Sir #{malceb}. He had a/an #{adj3} face and his #{noun1} was over #{numb1} feet long. As soon as her #{pln2} touched his #{noun2}, they fell in love. She felt a/an #{adj4} sensation rush through her #{body3}. They were married in #{build} the following day.\n\n Not long after, they had a baby. They named her #{femceb2} because she looked a/an #{animal}. They would #{verb} her #{numb2} times a day, so that her #{body4} would be shiny and #{adj5}. And they #{ptverb} happily ever after.\n\n The End\n\n\n"
8 Comments On This Entry
Page 1 of 1

xclite
25 June 2010 - 01:31 PM
Just a heads up - Ruby doesn't require you to put parens on method calls that have no arguments (i.e. when you're calling gets) if you don't want to - not that I'm saying you shouldn't =p. Also, if you call the string method chomp after gets, you'll get rid of those pesky newlines that break up your story.
animal = gets.chomp

Skaggles
25 June 2010 - 04:19 PM
It's always great to see people enjoying Ruby. And a mad libs program? YES!


NeoTifa
28 June 2010 - 11:34 AM
I used to love madlibs back in the day. I would always put retarded stuff in there. Makes the story so much funnier. Like one was a horror movie script, and it asked for 2 weapons, I said banana and hamster. Quite amusing.
Page 1 of 1
← January 2021 →
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
Tags
My Blog Links
Recent Entries
Recent Comments
Search My Blog
0 user(s) viewing
0 Guests
0 member(s)
0 anonymous member(s)
0 member(s)
0 anonymous member(s)