Module: Nanoc::CLI::ANSIStringColorizer Private
- Defined in:
- lib/nanoc/cli/ansi_string_colorizer.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
A simple ANSI colorizer for strings. When given a string and a list of attributes, it returns a colorized string.
Constant Summary collapse
- MAPPING =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
TODO: complete mapping
{ bold: "\e[1m", red: "\e[31m", green: "\e[32m", yellow: "\e[33m", blue: "\e[34m", }.freeze
Class Method Summary collapse
-
.c(str, *attrs) ⇒ String
private
A string colorized using the given attributes.
Class Method Details
.c(str, *attrs) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns A string colorized using the given attributes.
25 26 27 |
# File 'lib/nanoc/cli/ansi_string_colorizer.rb', line 25 def self.c(str, *attrs) attrs.map { |a| MAPPING[a] }.join('') + str + "\e[0m" end |