# Big Words (#204)

**URL:** <https://www.ruby-forum.com/t/big-words-204/167511>\
**Category:** Ruby\
**Created:** [May 8, 2009, 7:21pm UTC](https://www.ruby-forum.com/t/big-words-204/167511 "2009-05-08T19:21:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![danmcb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/13edae/32.png) [@danmcb](https://www.ruby-forum.com/u/danmcb)\
**Post date:** [May 8, 2009, 7:21pm UTC](https://www.ruby-forum.com/t/big-words-204/167511/1 "2009-05-08T19:21:08Z")

</div>

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

The three rules of Ruby Q.:

1. Please do not post any solutions or spoiler discussion for this  
quiz until 48 hours have elapsed from the time this message was  
sent.

2. Support Ruby Q. by submitting ideas and responses  
as often as you can!  
Visit: [http://rubyquiz.strd6.com/suggestions](http://rubyquiz.strd6.com/suggestions)

3. Enjoy!

Suggestion: A [QUIZ] in the subject of emails about the problem  
helps everyone on Ruby T. follow the discussion. Please reply to  
the original quiz message, if you can.

RSS Feed: [http://rubyquiz.strd6.com/quizzes.rss](http://rubyquiz.strd6.com/quizzes.rss)

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

## Big Words (#204)

Wassup Rubyists,

This weeks quiz was submitted by Alan.

Write a method that will return a large version of a string you provide  
it.

(Copy the output into a monospaced buffer for better viewing)

puts big\_word(‘BIGWORD’)

###### ####### ##### # # ##### ######

# # # # # # # # # # #

###### # # ### # # # # # ###### #

# # # # # # # # # # # # #

###### ####### ##### ## ## ##### # #

For extra credit you may include additional font styles, such as italic.

puts big\_word(‘BIGWORD’, ‘i’)

###### ####### ##### # # ##### ######

# # # # # # # # # # #

###### # # ### # # # # # ###### #

# # # # # # # # # # # # #

###### ####### ##### ## ## ##### # #

Have Fun!

---

<div class="post-metadata">

**Author:** ![danmcb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/13edae/32.png) [@danmcb](https://www.ruby-forum.com/u/danmcb)\
**Post date:** [May 15, 2009, 11:15pm UTC](https://www.ruby-forum.com/t/big-words-204/167511/2 "2009-05-15T23:15:44Z")

</div>

Daniel M. wrote:

> ## Big Words (#204)

This quiz immediately reminded me of FIGlet[1](http://www.figlet.org/). A reimplementation of  
FIGlet in Ruby seemed to be a sensible way to solve this quiz, taking  
into account the hundreds of fonts already available in the FIGlet  
format  
(saving me from creating my own font). Fortunately I wasn’t the first  
one to have that idea: the “Text” gem[2](http://text.rubyforge.org/) includes a Ruby implementation  
of FIGlet! So I couldn’t resist to do this:

#!/usr/bin/env ruby  
require ‘rubygems’  
require ‘text’

def big\_word(str, fontfile=‘banner.flf’)  
font = Text::Figlet::Font.new(fontfile)  
figlet = Text::Figlet::Typesetter.new(font)  
figlet[str]  
end

if **FILE** == $0  
while str = ARGV.shift  
puts big\_word(str)  
end  
end

Sample run:

reima@marvin:~/devel/ruby/quiz/204$ ./big\_word.rb “Ruby Q.”

###### 

# # # # ##### # # # # # # #

# # # # # # # # # # # # #

###### # # ##### # # # # # #

# # # # # # # # # # # # #

# # # # # # # # # # # #

# # #### ##### # #### # #### #

The font file needed to run the script can be obtained from [3](http://www.figlet.org/fonts/banner.flf). Or  
pick  
any font from the font database[4](http://www.figlet.org/fontdb.cgi) you fancy and change the file name in  
the script.

-Matthias

---

<div class="post-metadata">

**Author:** ![danmcb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/13edae/32.png) [@danmcb](https://www.ruby-forum.com/u/danmcb)\
**Post date:** [May 17, 2009, 7:41pm UTC](https://www.ruby-forum.com/t/big-words-204/167511/3 "2009-05-17T19:41:01Z")

</div>

This week’s quiz was solved by Matthias R… Let’s check out the  
solution:

```
require 'rubygems'
require 'text'

def big_word(str, fontfile='banner.flf')
  font = Text::Figlet::Font.new(fontfile)
  figlet = Text::Figlet::Typesetter.new(font)
  figlet[str]
end

```

Matthias uses the `Text` gem[1](http://text.rubyforge.org/) to display fonts using the FIGlet[2](http://www.figlet.org/)  
format. The `big_word` method takes an optional font file parameter to  
allow different styles. It operates by loading the file, creating a  
FIGlet Typesetter from the font, and passing the input string to the  
Typesetter. An easy to use and straightforward library.

There are a couple of prerequisites to use the program, though. You’ll  
need the `Text` gem and a font file[3](http://www.figlet.org/fonts/banner.flf). I found that when installing  
the gem, I needed to use the command `gem install Text`; the command  
with lowercase `text` wouldn’t work for me. Matthias also links to the  
FIGlet font database[4](http://www.figlet.org/fontdb.cgi) where there are some amazing fonts available.

In addition to FIGlet, the `Text` gem includes many other useful  
libraries like Metaphone and Soundex. The Metaphone component of the  
`Text` gem was used way back on Quiz #140[5](http://rubyquiz.com/quiz140.html) to sound out T-Shirts.

Thank you, Matthias, for sharing this useful library.

```
 ______  _____
/\ _`\ /\ \ /\ __`\__
\ \ \L\ \ ____ \ \ \ ______  __\ \ \/\ \__  __/\_\____
 \ \ , / /\ \/\ \ \ '__`\/\ \/\ \ \ \ \ \ \/\ \/\ \/\ \/\_ ,`\
  \ \ \\ \\ \ \_\ \ \ \L\ \ \ \_\ \ \ \ \\'\\ \ \_\ \ \ \/_/ /_
   \ \_\ \_\ \ ____/\ \_,__ /\/` ____\ \ \___ \_\ \ ____/\ \_\/\____ \
    \/_/\/ /\/ ___/ \/___ / `/ ___/> \ \/__ //_/\/ ___/ \/_/\/____ /
                               /\___/
                               \/__/

```
