| Class | Pastel::Color |
| In: |
lib/pastel/color.rb
|
| Parent: | Object |
A class responsible for coloring strings.
| ALIASES | = | {} | All color aliases | |
| ANSI_COLOR_REGEXP | = | /\x1b+(\[|\[\[)[0-9;:?]+m/mo.freeze | Match all color escape sequences |
| enabled | -> | enabled? |
| eachline | [R] | |
| enabled | [R] |
Define a new colors alias
@param [String] alias_name
the colors alias to define
@param [Array[Symbol,String]] color
the colors the alias will correspond to
@return [Array[String]]
the standard color values of the alias
@api public
Apply escape codes to the string
@param [String] string
the string to apply escapes to
@param [Strin] ansi_colors
the ansi colors to apply
@return [String]
return the string surrounded by escape codes
@api private
Return raw color code without embeding it into a string.
@return [Array[String]]
ANSI escape codes
@api public
Check if string has color escape codes
@param [String] string
the string to check for color strings
@return [Boolean]
true when string contains color codes, false otherwise
@api public
Find the escape code for a given set of color attributes
@example
color.lookup(:red, :on_green) # => "\e[31;42m"
@param [Array[Symbol]] colors
the list of color name(s) to lookup
@return [String]
the ANSI code(s)
@raise [InvalidAttributeNameError]
exception raised for any invalid color name
@api private