ssoroka / ansi
- Source
- Commits
- Network (0)
- Issues (0)
- Downloads (0)
- Wiki (1)
- Graphs
-
Tree:
c031625
ansi / README.rdoc
| 641a89fd » | ssoroka | 2008-11-12 | 1 | = ANSI | |
| 2 | |||||
| 8edf2457 » | ssoroka | 2008-11-12 | 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 | 10 | sudo gem install ssoroka-ansi | |
| 8edf2457 » | ssoroka | 2008-11-12 | 11 | ||
| 12 | as a plugin: | ||||
| 13 | script/plugin install git://github.com/ssoroka/ansi.git | ||||
| 14 | |||||
| 15 | == USAGE | ||||
| 16 | |||||
| aef91560 » | ssoroka | 2008-11-12 | 17 | require 'ansi' # if not installed as a plugin. | |
| 18 | |||||
| 8edf2457 » | ssoroka | 2008-11-12 | 19 | 1) Simply control the cursor: | |
| 9e7761b2 » | ssoroka | 2008-11-12 | 20 | >> puts "HELLO" + ANSI.right(30) + "THERE!" | |
| 21 | HELLO THERE! | ||||
| 8edf2457 » | ssoroka | 2008-11-12 | 22 | ||
| 23 | 2) use colors: | ||||
| 24 | |||||
| 9e7761b2 » | ssoroka | 2008-11-12 | 25 | >> puts ANSI.color(:red) { "hello there" } | |
| 26 | >> puts ANSI.color(:green) + "Everything is green now" + ANSI.no_color | ||||
| 8edf2457 » | ssoroka | 2008-11-12 | 27 | ||
| 28 | 3) loops: | ||||
| 29 | |||||
| 9e7761b2 » | ssoroka | 2008-11-12 | 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 | 38 | ||
