From: Ruby Quiz Date: 2005-10-21T21:45:40+09:00 Subject: [QUIZ] Ducksay (#52) The three rules of Ruby Quiz: 1. Please do not post any solutions or spoiler discussion for this quiz until 48 hours have passed from the time on this message. 2. Support Ruby Quiz by submitting ideas as often as you can: http://www.rubyquiz.com/ 3. Enjoy! -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= by Jonas Pfenniger __________________________________ < Welcome to this week's Ruby Quiz > ---------------------------------- \ ^__^ \ (oo)\_______ (__)\ )\/\ ||----w | || || This week, we will make some ascii-art for fun. Produce a script that generates funny talking animals. The executable consists of three parts. Part One : The balloon ===================== The balloon is the surrounding part, in which the text will be shown. You can make it like you want. Examples : One-liner _______________ < I love ruby ! > --------------- Multiple lines with text wrapping and carriage return __________________________________________ / Q:How do you stop an elephant from \ | charging? | \ A:Take away his credit cards. / ------------------------------------------ Part Two : The template ======================= To make it flexible, we'll need a template language that can combine the animal and the text. You'll have to think about how you want to make it flexible enough. Example : # thoughts is the balloon's tail def animal(thoughts = '\', eyes = 'oo', tongue=' ') %[#{baloon} #{thoughts} ^__^ #{thoughts} (#{eyes})\\_______ (__)\\ )\\/\\ #{tongue} ||----w | || || ] end Part Three : The command-line arguments ======================================= There are no special arguments. I would suggest asking for a text input, but you can also get the text from `fortune` or make it editable in place. Optional arguments can be given to change the selected template and some of its variables like the eyes, the tongue, and the balloon's tail. Use your imagination ! So that's it for the quiz. Extra points are given to the person who provides a duck template. Credits ======= - cowsay : http://www.cowsay.net/