class Rainbow::Presenter

Constants

TERM_EFFECTS

Public Instance Methods

background(*values) click to toggle source

Sets background color of this text.

# File lib/rainbow/presenter.rb, line 29
def background(*values)
  wrap_with_sgr(Color.build(:background, values).codes)
end
Also aliased as: bg
bg(*values)
Alias for: background
black() click to toggle source
# File lib/rainbow/presenter.rb, line 91
def black
  color(:black)
end
blue() click to toggle source
# File lib/rainbow/presenter.rb, line 107
def blue
  color(:blue)
end
bold()
Alias for: bright
bright() click to toggle source

Turns on bright/bold for this text.

# File lib/rainbow/presenter.rb, line 44
def bright
  wrap_with_sgr(TERM_EFFECTS[:bright])
end
Also aliased as: bold
color(*values) click to toggle source

Sets color of this text.

# File lib/rainbow/presenter.rb, line 21
def color(*values)
  wrap_with_sgr(Color.build(:foreground, values).codes)
end
Also aliased as: foreground, fg
cross_out() click to toggle source
# File lib/rainbow/presenter.rb, line 85
def cross_out
  wrap_with_sgr(TERM_EFFECTS[:cross_out])
end
Also aliased as: strike
cyan() click to toggle source
# File lib/rainbow/presenter.rb, line 115
def cyan
  color(:cyan)
end
dark()
Alias for: faint
faint() click to toggle source

Turns on faint/dark for this text (not well supported by terminal emulators).

# File lib/rainbow/presenter.rb, line 52
def faint
  wrap_with_sgr(TERM_EFFECTS[:faint])
end
Also aliased as: dark
fg(*values)
Alias for: color
foreground(*values)
Alias for: color
green() click to toggle source
# File lib/rainbow/presenter.rb, line 99
def green
  color(:green)
end
hide() click to toggle source

Hides this text (set its color to the same as background).

# File lib/rainbow/presenter.rb, line 81
def hide
  wrap_with_sgr(TERM_EFFECTS[:hide])
end
inverse() click to toggle source

Inverses current foreground/background colors.

# File lib/rainbow/presenter.rb, line 76
def inverse
  wrap_with_sgr(TERM_EFFECTS[:inverse])
end
italic() click to toggle source

Turns on italic style for this text (not well supported by terminal emulators).

# File lib/rainbow/presenter.rb, line 60
def italic
  wrap_with_sgr(TERM_EFFECTS[:italic])
end
magenta() click to toggle source
# File lib/rainbow/presenter.rb, line 111
def magenta
  color(:magenta)
end
method_missing(method_name, *args) click to toggle source

We take care of X11 color method call here. Such as aqua, ghostwhite.

Calls superclass method
# File lib/rainbow/presenter.rb, line 125
def method_missing(method_name, *args)
  if Color::X11Named.color_names.include?(method_name) && args.empty?
    color(method_name)
  else
    super
  end
end
red() click to toggle source
# File lib/rainbow/presenter.rb, line 95
def red
  color(:red)
end
reset() click to toggle source

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.

# File lib/rainbow/presenter.rb, line 39
def reset
  wrap_with_sgr(TERM_EFFECTS[:reset])
end
respond_to_missing?(method_name, *args) click to toggle source
Calls superclass method
# File lib/rainbow/presenter.rb, line 133
def respond_to_missing?(method_name, *args)
  Color::X11Named.color_names.include?(method_name) && args.empty? || super
end
strike()
Alias for: cross_out
underline() click to toggle source

Turns on underline decoration for this text.

# File lib/rainbow/presenter.rb, line 65
def underline
  wrap_with_sgr(TERM_EFFECTS[:underline])
end
white() click to toggle source
# File lib/rainbow/presenter.rb, line 119
def white
  color(:white)
end
yellow() click to toggle source
# File lib/rainbow/presenter.rb, line 103
def yellow
  color(:yellow)
end