Sha256: 3db18c1e044029664963492e273fa4c8ef2e4f1ecc4840704d49ba56dc631785
Contents?: true
Size: 1.09 KB
Versions: 28
Compression:
Stored size: 1.09 KB
Contents
# typed: strict # frozen_string_literal: true module Spoom class Color < T::Enum extend T::Sig enums do CLEAR = new("\e[0m") BOLD = new("\e[1m") BLACK = new("\e[30m") RED = new("\e[31m") GREEN = new("\e[32m") YELLOW = new("\e[33m") BLUE = new("\e[34m") MAGENTA = new("\e[35m") CYAN = new("\e[36m") WHITE = new("\e[37m") LIGHT_BLACK = new("\e[90m") LIGHT_RED = new("\e[91m") LIGHT_GREEN = new("\e[92m") LIGHT_YELLOW = new("\e[93m") LIGHT_BLUE = new("\e[94m") LIGHT_MAGENTA = new("\e[95m") LIGHT_CYAN = new("\e[96m") LIGHT_WHITE = new("\e[97m") end sig { returns(String) } def ansi_code serialize end end module Colorize extend T::Sig sig { params(string: String, color: Color).returns(String) } def set_color(string, *color) "#{color.map(&:ansi_code).join}#{string}#{Color::CLEAR.ansi_code}" end end end
Version data entries
28 entries across 28 versions & 2 rubygems