Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/spout/color.rb
Overview
Adds ANSI colors to string class.
Instance Method Summary collapse
- #bg_black ⇒ Object
- #bg_blue ⇒ Object
- #bg_brown ⇒ Object
- #bg_cyan ⇒ Object
- #bg_gray ⇒ Object
- #bg_green ⇒ Object
- #bg_magenta ⇒ Object
- #bg_red ⇒ Object
- #black ⇒ Object
- #blink ⇒ Object
- #blue ⇒ Object
- #bold ⇒ Object
- #brown ⇒ Object
- #colorless ⇒ Object
- #cyan ⇒ Object
- #gray ⇒ Object
- #green ⇒ Object
- #italic ⇒ Object
- #magenta ⇒ Object
- #red ⇒ Object
- #reverse_color ⇒ Object
- #underline ⇒ Object
- #white ⇒ Object
- #yellow ⇒ Object
Instance Method Details
#bg_black ⇒ Object
45 46 47 |
# File 'lib/spout/color.rb', line 45 def bg_black "\e[40m#{self}\e[0m" end |
#bg_blue ⇒ Object
61 62 63 |
# File 'lib/spout/color.rb', line 61 def bg_blue "\e[44m#{self}\e[0m" end |
#bg_brown ⇒ Object
57 58 59 |
# File 'lib/spout/color.rb', line 57 def bg_brown "\e[43m#{self}\e[0m" end |
#bg_cyan ⇒ Object
69 70 71 |
# File 'lib/spout/color.rb', line 69 def bg_cyan "\e[46m#{self}\e[0m" end |
#bg_gray ⇒ Object
73 74 75 |
# File 'lib/spout/color.rb', line 73 def bg_gray "\e[47m#{self}\e[0m" end |
#bg_green ⇒ Object
53 54 55 |
# File 'lib/spout/color.rb', line 53 def bg_green "\e[42m#{self}\e[0m" end |
#bg_magenta ⇒ Object
65 66 67 |
# File 'lib/spout/color.rb', line 65 def bg_magenta "\e[45m#{self}\e[0m" end |
#bg_red ⇒ Object
49 50 51 |
# File 'lib/spout/color.rb', line 49 def bg_red "\e[41m#{self}\e[0m" end |
#black ⇒ Object
5 6 7 |
# File 'lib/spout/color.rb', line 5 def black "\e[30m#{self}\e[0m" end |
#blink ⇒ Object
89 90 91 |
# File 'lib/spout/color.rb', line 89 def blink "\e[5m#{self}\e[25m" end |
#blue ⇒ Object
25 26 27 |
# File 'lib/spout/color.rb', line 25 def blue "\e[34m#{self}\e[0m" end |
#bold ⇒ Object
77 78 79 |
# File 'lib/spout/color.rb', line 77 def bold "\e[1m#{self}\e[22m" end |
#brown ⇒ Object
17 18 19 |
# File 'lib/spout/color.rb', line 17 def brown "\e[33m#{self}\e[0m" end |
#colorless ⇒ Object
97 98 99 |
# File 'lib/spout/color.rb', line 97 def colorless gsub(/\e\[\d{1,2}m/, "") end |
#cyan ⇒ Object
33 34 35 |
# File 'lib/spout/color.rb', line 33 def cyan "\e[36m#{self}\e[0m" end |
#gray ⇒ Object
37 38 39 |
# File 'lib/spout/color.rb', line 37 def gray "\e[37m#{self}\e[0m" end |
#green ⇒ Object
13 14 15 |
# File 'lib/spout/color.rb', line 13 def green "\e[32m#{self}\e[0m" end |
#italic ⇒ Object
81 82 83 |
# File 'lib/spout/color.rb', line 81 def italic "\e[3m#{self}\e[23m" end |
#magenta ⇒ Object
29 30 31 |
# File 'lib/spout/color.rb', line 29 def magenta "\e[35m#{self}\e[0m" end |
#red ⇒ Object
9 10 11 |
# File 'lib/spout/color.rb', line 9 def red "\e[31m#{self}\e[0m" end |
#reverse_color ⇒ Object
93 94 95 |
# File 'lib/spout/color.rb', line 93 def reverse_color "\e[7m#{self}\e[27m" end |
#underline ⇒ Object
85 86 87 |
# File 'lib/spout/color.rb', line 85 def underline "\e[4m#{self}\e[24m" end |
#white ⇒ Object
41 42 43 |
# File 'lib/spout/color.rb', line 41 def white "\e[39m#{bold}\e[0m" end |
#yellow ⇒ Object
21 22 23 |
# File 'lib/spout/color.rb', line 21 def yellow brown end |