How can I print the string in different color?

Hai Friends,
            How can I print the string in different color in Ruby.
For example,we can take c program,I c program we are having the printing
foramts with lot of colors.

by
vellingiri

···

--
Posted via http://www.ruby-forum.com/.

Arul hari a écrit :

Hai Friends,
            How can I print the string in different color in Ruby.
For example,we can take c program,I c program we are having the printing
foramts with lot of colors.

by
vellingiri

gem install colorize

Does the word "color" looked very strange to anyone else?

Hai Friends,
            How can I print the string in different color in Ruby.
For example,we can take c program,I c program we are having the printing
foramts with lot of colors.

Check out the HighLine library for that!

Example:

say("This should be <%= color('red', :red) %>!")

notice the hacky use of erb in the string. Sly move there, JEG & Greg!

Also, once you install it, you can try a cool little hack I have (in honor of me not doing my chemistry homework):
module Kernel
   def color(string, color)
     return HighLine.new.color(string, color)
   end
end

say color("hooray! red!", :red)

that way you don't have to use erb.

~ Ari
English is like a pseudo-random number generator - there are a bajillion rules to it, but nobody cares.

···

On Oct 23, 2007, at 4:49 AM, Arul hari wrote: