Class Pastel::ColorParser
In: lib/pastel/color_parser.rb
Parent: Object

Responsible for parsing color symbols out of text with color escapes

Used internally by {Color}.

@api private

Methods

Included Modules

ANSI

Constants

ESC = "\x1b".freeze
CSI = "\[".freeze

Public Class methods

@api private

Decide attribute name for ansi

@param [Integer] ansi

  the ansi escape code

@return [Symbol]

@api private

Parse color escape sequences into a list of hashes corresponding to the color attributes being set by these sequences

@example

  parse("\e[32mfoo\e[0m") # => [{colors: [:green], text: 'foo'}

@param [String] text

  the text to parse for presence of color ansi codes

@return [Array[Hash[Symbol,String]]]

@api public

Remove from current stack all ansi codes

@param [Array[Integer]] ansi_stack

  the stack with all the ansi codes

@yield [Symbol, Symbol] attr, name

@api private

[Validate]