Class: Rainbow::Wrapper

Inherits:
String
  • Object
show all
Defined in:
lib/rainbow/wrapper.rb

Instance Method Summary collapse

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

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

#brightObject

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

#hideObject

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

#inverseObject

Inverses current foreground/background colors.



53
54
55
# File 'lib/rainbow/wrapper.rb', line 53

def inverse
  wrap_with_sgr(TERM_EFFECTS[:inverse])
end

#italicObject

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

#resetObject

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

#underlineObject

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