Class: Rainbow::Presenter
- Inherits:
-
String
- Object
- String
- Rainbow::Presenter
- Defined in:
- lib/rainbow/presenter.rb
Constant Summary collapse
- TERM_EFFECTS =
{ :reset => 0, :bright => 1, :italic => 3, :underline => 4, :blink => 5, :inverse => 7, :hide => 8, }
Instance Method Summary collapse
-
#background(*values) ⇒ Object
(also: #bg)
Sets background color of this text.
- #black ⇒ Object
-
#blink ⇒ Object
Turns on blinking attribute for this text (not well supported by terminal emulators).
- #blue ⇒ Object
-
#bright ⇒ Object
Turns on bright/bold for this text.
-
#color(*values) ⇒ Object
(also: #foreground, #fg)
Sets color of this text.
- #cyan ⇒ Object
- #green ⇒ Object
-
#hide ⇒ Object
Hides this text (set its color to the same as background).
-
#inverse ⇒ Object
Inverses current foreground/background colors.
-
#italic ⇒ Object
Turns on italic style for this text (not well supported by terminal emulators).
- #magenta ⇒ Object
- #red ⇒ Object
-
#reset ⇒ Object
Resets terminal to default colors/backgrounds.
-
#underline ⇒ Object
Turns on underline decoration for this text.
- #white ⇒ Object
- #yellow ⇒ Object
Instance Method Details
#background(*values) ⇒ Object Also known as: bg
Sets background color of this text.
27 28 29 |
# File 'lib/rainbow/presenter.rb', line 27 def background(*values) wrap_with_sgr(Color.build(:background, values).codes) end |
#black ⇒ Object
73 74 75 |
# File 'lib/rainbow/presenter.rb', line 73 def black color(:black) end |
#blink ⇒ Object
Turns on blinking attribute for this text (not well supported by terminal emulators).
59 60 61 |
# File 'lib/rainbow/presenter.rb', line 59 def blink wrap_with_sgr(TERM_EFFECTS[:blink]) end |
#blue ⇒ Object
89 90 91 |
# File 'lib/rainbow/presenter.rb', line 89 def blue color(:blue) end |
#bright ⇒ Object
Turns on bright/bold for this text.
42 43 44 |
# File 'lib/rainbow/presenter.rb', line 42 def bright wrap_with_sgr(TERM_EFFECTS[:bright]) end |
#color(*values) ⇒ Object Also known as: foreground, fg
Sets color of this text.
19 20 21 |
# File 'lib/rainbow/presenter.rb', line 19 def color(*values) wrap_with_sgr(Color.build(:foreground, values).codes) end |
#cyan ⇒ Object
97 98 99 |
# File 'lib/rainbow/presenter.rb', line 97 def cyan color(:cyan) end |
#green ⇒ Object
81 82 83 |
# File 'lib/rainbow/presenter.rb', line 81 def green color(:green) end |
#hide ⇒ Object
Hides this text (set its color to the same as background).
69 70 71 |
# File 'lib/rainbow/presenter.rb', line 69 def hide wrap_with_sgr(TERM_EFFECTS[:hide]) end |
#inverse ⇒ Object
Inverses current foreground/background colors.
64 65 66 |
# File 'lib/rainbow/presenter.rb', line 64 def inverse wrap_with_sgr(TERM_EFFECTS[:inverse]) end |
#italic ⇒ Object
Turns on italic style for this text (not well supported by terminal emulators).
48 49 50 |
# File 'lib/rainbow/presenter.rb', line 48 def italic wrap_with_sgr(TERM_EFFECTS[:italic]) end |
#magenta ⇒ Object
93 94 95 |
# File 'lib/rainbow/presenter.rb', line 93 def magenta color(:magenta) end |
#red ⇒ Object
77 78 79 |
# File 'lib/rainbow/presenter.rb', line 77 def red color(:red) end |
#reset ⇒ Object
Resets terminal to default colors/backgrounds.
It shouldn’t be needed to use this method because all methods append terminal reset code to end of string.
37 38 39 |
# File 'lib/rainbow/presenter.rb', line 37 def reset wrap_with_sgr(TERM_EFFECTS[:reset]) end |
#underline ⇒ Object
Turns on underline decoration for this text.
53 54 55 |
# File 'lib/rainbow/presenter.rb', line 53 def underline wrap_with_sgr(TERM_EFFECTS[:underline]) end |
#white ⇒ Object
101 102 103 |
# File 'lib/rainbow/presenter.rb', line 101 def white color(:white) end |
#yellow ⇒ Object
85 86 87 |
# File 'lib/rainbow/presenter.rb', line 85 def yellow color(:yellow) end |