Skip to content

Instantly share code, notes, and snippets.

@illbzo1
Created October 29, 2011 00:32
Show Gist options
  • Save illbzo1/1323920 to your computer and use it in GitHub Desktop.
Save illbzo1/1323920 to your computer and use it in GitHub Desktop.
Simple MadLibs generator
def prompt
print "> "
end
def generate_mad_lib
puts "Bear with me. I'm going to need 18 singular @nouns."
prompt;
@noun1 = gets.chomp()
@noun2 = gets.chomp()
@noun3 = gets.chomp()
@noun4 = gets.chomp()
@noun5 = gets.chomp()
@noun6 = gets.chomp()
@noun7 = gets.chomp()
@noun8 = gets.chomp()
@noun9 = gets.chomp()
@noun10 = gets.chomp()
@noun11 = gets.chomp()
@noun12 = gets.chomp()
@noun13 = gets.chomp()
@noun14 = gets.chomp()
@noun15 = gets.chomp()
@noun16 = gets.chomp()
@noun17 = gets.chomp()
@noun18 = gets.chomp()
puts "Awesome, now I'm going to need 5 plural @nouns."
prompt;
@nouns1 = gets.chomp()
@nouns2 = gets.chomp()
@nouns3 = gets.chomp()
@nouns4 = gets.chomp()
@nouns5 = gets.chomp()
puts "Ok, now let's collect some singular @verbs. I'm looking for 7 of them."
prompt;
@verb1 = gets.chomp()
@verb2 = gets.chomp()
@verb3 = gets.chomp()
@verb4 = gets.chomp()
@verb5 = gets.chomp()
@verb6 = gets.chomp()
@verb7 = gets.chomp()
puts "Almost done! Now we need 5 @verbs in the present tense, such as running or leaping."
prompt;
@verbing1 = gets.chomp()
@verbing2 = gets.chomp()
@verbing3 = gets.chomp()
@verbing4 = gets.chomp()
@verbing5 = gets.chomp()
puts "You like @adjectives? Hey, me too! I'm going to need 4 of them."
prompt;
@adjective1 = gets.chomp()
@adjective2 = gets.chomp()
@adjective3 = gets.chomp()
@adjective4 = gets.chomp()
puts "And finally, we need just one @number. Any @number at all. Really!"
prompt;
@number = gets.chomp()
end
generate_mad_lib()
require_relative 'mermaid'
def mermaid_lib
puts <<-LITTLE_MERMAID
Look at this #{@noun1}, isn`t it neat?
Wouldn`t you think my collection`s complete?
Wouldn`t you think I`m the #{@noun2}
The #{@noun3} who has everything?
Look at this #{@noun4}, treasures untold
How many wonders can one #{@noun5} hold?
#{@verbing1} around here, you`d think
Sure, she`s got everything
I`ve got #{@noun6} and #{@nouns1} a-plenty
I`ve got who`s-its and what`s-its galore
You #{@verb1} thing-a-mabobs?
I`ve got #{@number}
But who cares? No #{@adjective1} deal. I #{@verb2} more
I wanna be where the #{@nouns2} are
I wanna see, wanna see `em #{@verbing2}
walkin` around on those
Whaddya call `em? Oh, feet
#{@verbing3} your fins, you don`t get too far
Legs are required for #{@verbing4}, dancin`
Strollin` along down the
What`s that word again? #{@noun7}
Up where #{@noun8} #{@verb3}
Up where #{@noun9} run
Up where #{@noun10} stay all day in the sun
Wanderin` free, wish I could be
Part of that #{@noun11}
What would I give if I could live
Outta these #{@nouns3}?
What would I pay to spend a day
#{@adjective2} on the sand?
Betcha on #{@noun11} they understand
Bet they don`t reprimand their #{@nouns4}
Bright young #{@nouns5}, sick of #{@verbing5}
Ready to stand
And ready to know what the #{@noun13} know
Ask `em #{@adjective3} questions and get some answers
What`s a #{@noun14}, and why does it
What`s the word? #{@verb4}
When`s it my turn?
Wouldn`t I #{@verb5}?
#{@verb6} to explore that #{@noun15} up above
Out of #{@adjective4} #{@noun16}, wish #{@noun17} could be
#{@verb7} of that #{@noun18}
LITTLE_MERMAID
end
mermaid_lib()
@jqr
Copy link

jqr commented Oct 29, 2011

Good, but can you simplify it?

@illbzo1
Copy link
Author

illbzo1 commented Oct 30, 2011

@jqr absolutely, and that's my goal for this week. I'm sure there's an easier way of collecting, storing and retrieving the nouns, adjectives, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment