Sha256: c9621fde9a49b20fa9a20bd5dc399e4cac64e4eb9f4a0825c064b9ec6b784bd1
Contents?: true
Size: 1.35 KB
Versions: 3
Compression:
Stored size: 1.35 KB
Contents
require 'dev/ui' module Dev module UI class Color attr_reader :sgr, :name, :code def initialize(sgr, name) @sgr = sgr @code = Dev::UI::ANSI.sgr(sgr) @name = name end RED = new('31', :red) GREEN = new('32', :green) YELLOW = new('33', :yellow) # default blue is low-contrast against black in some default terminal color scheme BLUE = new('94', :blue) # 9x = high-intensity fg color x MAGENTA = new('35', :magenta) CYAN = new('36', :cyan) RESET = new('0', :reset) BOLD = new('1', :bold) WHITE = new('97', :white) MAP = { red: RED, green: GREEN, yellow: YELLOW, blue: BLUE, magenta: MAGENTA, cyan: CYAN, reset: RESET, bold: BOLD, }.freeze class InvalidColorName < ArgumentError def initialize(name) @name = name end def message keys = Color.available.map(&:inspect).join(',') "invalid color: #{@name.inspect} " \ "-- must be one of Dev::UI::Color.available (#{keys})" end end def self.lookup(name) MAP.fetch(name) rescue KeyError raise InvalidColorName, name end def self.available MAP.keys end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dev-ui-0.1.0 | lib/dev/ui/color.rb |
dev-ui-0.0.2 | lib/dev/ui/color.rb |
dev-ui-0.0.1 | lib/dev/ui/color.rb |