Class: SuperDiff::Csi::EightBitColor
- Inherits:
-
Object
- Object
- SuperDiff::Csi::EightBitColor
- Defined in:
- lib/super_diff/csi/eight_bit_color.rb
Constant Summary collapse
- VALID_COMPONENT_RANGE =
0..6
- VALID_CODE_RANGE =
0..255
- VALID_CODES_BY_NAME =
{ black: 0, red: 1, green: 2, yellow: 3, blue: 4, magenta: 5, cyan: 6, white: 7, bright_black: 8, bright_red: 9, bright_green: 10, bright_yellow: 11, bright_blue: 12, bright_magenta: 13, bright_cyan: 14, bright_white: 15, }.freeze
- STARTING_INDICES =
{ standard: 0, high_intensity: 8, grayscale: 232, }.freeze
- VALID_PAIR_TYPES =
STARTING_INDICES.keys
- VALID_PAIR_INDEX_RANGES =
{ standard: 0..7, high_intensity: 0..7, grayscale: 0..23, }.freeze
- LEADING_CODES_BY_LAYER =
{ fg: 38, bg: 48 }.freeze
- SERIAL_CODE =
5
Instance Method Summary collapse
-
#initialize(value) ⇒ EightBitColor
constructor
A new instance of EightBitColor.
- #sequence_for(layer) ⇒ Object
Constructor Details
#initialize(value) ⇒ EightBitColor
Returns a new instance of EightBitColor.
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/super_diff/csi/eight_bit_color.rb', line 38 def initialize(value) @code = case value when Hash interpret_triplet!(value) when Symbol interpret_color_name!(value) when Array interpret_pair!(value) else interpret_code!(value) end end |
Instance Method Details
#sequence_for(layer) ⇒ Object
52 53 54 55 |
# File 'lib/super_diff/csi/eight_bit_color.rb', line 52 def sequence_for(layer) leading_code = LEADING_CODES_BY_LAYER.fetch(layer) "\e[#{leading_code};#{SERIAL_CODE};#{code}m" end |