Sha256: 65a4c139d35010ba9f2221665305a15a6146d83596c270adf6e7601a9b2fa5a7
Contents?: true
Size: 499 Bytes
Versions: 22
Compression:
Stored size: 499 Bytes
Contents
# frozen_string_literal: true # Create colorizing methods in the 'String' class, but only if 'colors_enabled' # has been set. class String COLORS = { 'red' => 31, 'green' => 32, 'yellow' => 33, 'cyan' => 36 }.freeze COLORS.each do |color, _value| define_method(color) do @@colors_enabled ? "\e[0;#{COLORS[color]};49m#{self}\e[0m" : self end end def self.colors_enabled=(value) @@colors_enabled = value # rubocop:disable Style/ClassVars end end
Version data entries
22 entries across 22 versions & 1 rubygems