class Dev::UI::Color

Constants

BLUE

default blue is low-contrast against black in some default terminal color scheme

BOLD
CYAN
GREEN
MAGENTA
MAP
RED
RESET
WHITE
YELLOW

Attributes

code[R]
name[R]
sgr[R]

Public Class Methods

available() click to toggle source

All available colors by name

# File lib/dev/ui/color.rb, line 74
def self.available
  MAP.keys
end
lookup(name) click to toggle source

Looks up a color code by name

Raises

Raises a InvalidColorName if the color is not available You likely need to add it to the MAP or you made a typo

Returns

Returns a color code

# File lib/dev/ui/color.rb, line 66
def self.lookup(name)
  MAP.fetch(name)
rescue KeyError
  raise InvalidColorName, name
end
new(sgr, name) click to toggle source

Creates a new color mapping Signatures can be found here: en.wikipedia.org/wiki/ANSI_escape_code#Colors

Attributes

  • sgr - The color signature

  • name - The name of the color

# File lib/dev/ui/color.rb, line 17
def initialize(sgr, name)
  @sgr  = sgr
  @code = Dev::UI::ANSI.sgr(sgr)
  @name = name
end