Sha256: 615a0d124f7f1b7e6650b5af563f2245b4492fc8fb09655616fc080aa3f58dfb
Contents?: true
Size: 728 Bytes
Versions: 28
Compression:
Stored size: 728 Bytes
Contents
# frozen_string_literal: true module Nanoc::CLI # A simple ANSI colorizer for strings. When given a string and a list of # attributes, it returns a colorized string. # # @api private module ANSIStringColorizer # TODO: complete mapping MAPPING = { bold: "\e[1m", red: "\e[31m", green: "\e[32m", yellow: "\e[33m", blue: "\e[34m", }.freeze # @param [String] str The string to colorize # # @param [Array] attrs An array of attributes from `MAPPING` to colorize the # string with # # @return [String] A string colorized using the given attributes def self.c(str, *attrs) attrs.map { |a| MAPPING[a] }.join('') + str + "\e[0m" end end end
Version data entries
28 entries across 28 versions & 1 rubygems