ssoroka / ansi

Use ANSI codes in printed output, including colors and controlling the cursor, clearing the line, and clearing the screen.

This URL has Read+Write access

ansi / README.rdoc
641a89fd » ssoroka 2008-11-12 first 1 = ANSI
2
8edf2457 » ssoroka 2008-11-12 docs, plugin stuff 3 == DESCRIPTION
4
5 Use ANSI codes in printed output, including colors and controlling the cursor, clearing the line, and clearing the screen.
6
7 == INSTALLATION
8
9 as a gem:
c0316255 » ssoroka 2008-12-15 typo fix 10 sudo gem install ssoroka-ansi
8edf2457 » ssoroka 2008-11-12 docs, plugin stuff 11
12 as a plugin:
13 script/plugin install git://github.com/ssoroka/ansi.git
14
15 == USAGE
16
aef91560 » ssoroka 2008-11-12 doc updates 17 require 'ansi' # if not installed as a plugin.
18
8edf2457 » ssoroka 2008-11-12 docs, plugin stuff 19 1) Simply control the cursor:
9e7761b2 » ssoroka 2008-11-12 doc fix 20 >> puts "HELLO" + ANSI.right(30) + "THERE!"
21 HELLO THERE!
8edf2457 » ssoroka 2008-11-12 docs, plugin stuff 22
23 2) use colors:
24
9e7761b2 » ssoroka 2008-11-12 doc fix 25 >> puts ANSI.color(:red) { "hello there" }
26 >> puts ANSI.color(:green) + "Everything is green now" + ANSI.no_color
8edf2457 » ssoroka 2008-11-12 docs, plugin stuff 27
28 3) loops:
29
9e7761b2 » ssoroka 2008-11-12 doc fix 30 printf ANSI.clear_screen
31 puts "Processing users..."
32 max = User.count
33 User.all.each_with_index {|user, index|
34 user.update_something!
35 printf ANSI.left(50) + "Processed #{index}/#{max} users..."
36 }
37 puts " done!"
8edf2457 » ssoroka 2008-11-12 docs, plugin stuff 38