Class: Rainbow::Wrapper
- Inherits:
-
String
- Object
- String
- Rainbow::Wrapper
- Defined in:
- lib/rainbow/wrapper.rb
Instance Method Summary collapse
-
#background(*values) ⇒ Object
Sets background color of this text.
-
#blink ⇒ Object
Turns on blinking attribute for this text (not well supported by terminal emulators).
-
#bright ⇒ Object
Turns on bright/bold for this text.
-
#foreground(*values) ⇒ Object
(also: #color, #colour)
Sets foreground color of this text.
-
#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).
-
#reset ⇒ Object
Resets terminal to default colors/backgrounds.
-
#underline ⇒ Object
Turns on underline decoration for this text.
Instance Method Details
#background(*values) ⇒ Object
Sets background color of this text.
18 19 20 |
# File 'lib/rainbow/wrapper.rb', line 18 def background(*values) wrap_with_sgr(Color.build(:background, values).codes) end |
#blink ⇒ Object
Turns on blinking attribute for this text (not well supported by terminal emulators).
48 49 50 |
# File 'lib/rainbow/wrapper.rb', line 48 def blink wrap_with_sgr(TERM_EFFECTS[:blink]) end |
#bright ⇒ Object
Turns on bright/bold for this text.
31 32 33 |
# File 'lib/rainbow/wrapper.rb', line 31 def bright wrap_with_sgr(TERM_EFFECTS[:bright]) end |
#foreground(*values) ⇒ Object Also known as: color, colour
Sets foreground color of this text.
10 11 12 |
# File 'lib/rainbow/wrapper.rb', line 10 def foreground(*values) wrap_with_sgr(Color.build(:foreground, values).codes) end |
#hide ⇒ Object
Hides this text (set its color to the same as background).
58 59 60 |
# File 'lib/rainbow/wrapper.rb', line 58 def hide wrap_with_sgr(TERM_EFFECTS[:hide]) end |
#inverse ⇒ Object
Inverses current foreground/background colors.
53 54 55 |
# File 'lib/rainbow/wrapper.rb', line 53 def inverse wrap_with_sgr(TERM_EFFECTS[:inverse]) end |
#italic ⇒ Object
Turns on italic style for this text (not well supported by terminal emulators).
37 38 39 |
# File 'lib/rainbow/wrapper.rb', line 37 def italic wrap_with_sgr(TERM_EFFECTS[:italic]) 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.
26 27 28 |
# File 'lib/rainbow/wrapper.rb', line 26 def reset wrap_with_sgr(TERM_EFFECTS[:reset]) end |
#underline ⇒ Object
Turns on underline decoration for this text.
42 43 44 |
# File 'lib/rainbow/wrapper.rb', line 42 def underline wrap_with_sgr(TERM_EFFECTS[:underline]) end |