Class: Color
- Inherits:
-
Object
- Object
- Color
- Defined in:
- lib/toolman/color.rb
Instance Method Summary collapse
- #blue(string) ⇒ Object
- #blue!(string) ⇒ Object
- #color_list ⇒ Object
- #colorize1(text, color_code) ⇒ Object
- #colorize2(text, color_code) ⇒ Object
- #cyan(string) ⇒ Object
- #cyan!(string) ⇒ Object
- #green(string) ⇒ Object
- #green!(string) ⇒ Object
- #red(string) ⇒ Object
- #red!(string) ⇒ Object
- #white(string) ⇒ Object
- #yellow(string) ⇒ Object
- #yellow!(string) ⇒ Object
Instance Method Details
#blue(string) ⇒ Object
26 27 28 |
# File 'lib/toolman/color.rb', line 26 def blue(string) puts colorize1(string, 34) end |
#blue!(string) ⇒ Object
30 31 32 |
# File 'lib/toolman/color.rb', line 30 def blue!(string) puts colorize2(string, 34) end |
#color_list ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/toolman/color.rb', line 54 def color_list print "puts.red \"string\" => ";red("string"); print "puts.red! \"string\" => ";red!("string"); print "puts.green \"string\" => ";green("string"); print "puts.green! \"string\" => ";green!("string"); print "puts.yellow \"string\" => ";yellow("string"); print "puts.yellow! \"string\" => ";yellow!("string"); print "puts.blue \"string\" => ";blue("string"); print "puts.blue! \"string\" => ";blue!("string"); print "puts.cyan \"string\" => ";cyan("string"); print "puts.cyan! \"string\" => ";cyan!("string"); print "puts.white \"string\" => ";white("string"); end |
#colorize1(text, color_code) ⇒ Object
50 51 52 |
# File 'lib/toolman/color.rb', line 50 def colorize1(text, color_code) "\e[#{color_code}m#{text}\e[0m" end |
#colorize2(text, color_code) ⇒ Object
47 48 49 |
# File 'lib/toolman/color.rb', line 47 def colorize2(text, color_code) "\e[1;#{color_code}m#{text}\e[0m" end |
#cyan(string) ⇒ Object
34 35 36 |
# File 'lib/toolman/color.rb', line 34 def cyan(string) puts colorize1(string, 36) end |
#cyan!(string) ⇒ Object
38 39 40 |
# File 'lib/toolman/color.rb', line 38 def cyan!(string) puts colorize2(string, 36) end |
#green(string) ⇒ Object
10 11 12 |
# File 'lib/toolman/color.rb', line 10 def green(string) puts colorize1(string, 32) end |
#green!(string) ⇒ Object
14 15 16 |
# File 'lib/toolman/color.rb', line 14 def green!(string) puts colorize2(string, 32) end |
#red(string) ⇒ Object
2 3 4 |
# File 'lib/toolman/color.rb', line 2 def red(string) puts colorize1(string, 31) end |
#red!(string) ⇒ Object
6 7 8 |
# File 'lib/toolman/color.rb', line 6 def red!(string) puts colorize2(string, 31) end |
#white(string) ⇒ Object
42 43 44 |
# File 'lib/toolman/color.rb', line 42 def white(string) puts colorize2(string, 37) end |
#yellow(string) ⇒ Object
18 19 20 |
# File 'lib/toolman/color.rb', line 18 def yellow(string) puts colorize1(string, 33) end |
#yellow!(string) ⇒ Object
22 23 24 |
# File 'lib/toolman/color.rb', line 22 def yellow!(string) puts colorize2(string, 33) end |