# Get the parts of speech
print "Please enter a past-tense verb: "
verb = gets.chomp
print "Please enter a noun: "
noun = gets.chomp
print "Please enter a proper noun: "
prop_noun = gets.chomp
print "Please enter a an adverb: "
adv = gets.chomp
# Make the sentence.
print "#{prop_noun} got a #{noun} and\n#{verb} #{adv} around the block.\n"
The built-in
gets
function simply reads a line and
returns it as a string. The
chomp
method from
class String
trims the line terminator.
The prompts are generated with ordinary prints lacking a
final newline.