Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Formatting Ruby Text?
Carter Davis
11/9/2008 8:52:00 PM
Hello. I was wondering...Is it possible to format text in Ruby besides
using the string literals like \n or \t? For example, can you make text
bold?
--
Posted via
http://www.ruby-...
.
1 Answer
Stefan Rusterholz
11/9/2008 10:55:00 PM
0
Carter Davis wrote:
> Hello. I was wondering...Is it possible to format text in Ruby besides
> using the string literals like \n or \t? For example, can you make text
> bold?
Not sure I understand your question correctly. If you mean the
source-code then you're looking for a syntax highlighting editor which
doesn't touch the text at all but just highlights it.
If you mean when outputting e.g. via puts then it entirely depends on
your output device. If it is a terminal that supports ANSII escape
sequences then you can use them. Look for the Term::ANSIColor gem on
rubyforge for a convenient way to do that. Plain it is like this:
puts "\e[1mBold\e[0m"
puts "\e[31mRed\e[0m"
With the gem you can do it like this:
puts "Bold".bold
puts "Red".red
(iirc)
Regards
Stefan
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Formatting Ruby Text?
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password