Class: Configs::Console::Color
Overview
Represents a terminal color with optional TrueColor (RGB) support.
Each color has a required ANSI fallback value for terminals that do not support TrueColor.
Instance Attribute Summary collapse
-
#ansi_fallback ⇒ Integer
16-color ANSI fallback code.
-
#blue ⇒ Integer?
Blue component (0–255), or nil if fallback-only.
-
#green ⇒ Integer?
Green component (0–255), or nil if fallback-only.
-
#red ⇒ Integer?
Red component (0–255), or nil if fallback-only.
Instance Method Summary collapse
-
#ansi
Returns the ANSI fallback value.
-
#ansi=(ansi)
Sets the ANSI fallback value.
-
#initialize(ansi_fallback, red = nil, green = nil, blue = nil) ⇒ Color
constructor
Creates a new color.
-
#set_color(red, green, blue)
Sets the RGB color values.
-
#to_ansi_str ⇒ String
Converts the RGB values into a TrueColor ANSI escape sequence.
-
#use_fallback? ⇒ Boolean
Whether this color should use its ANSI fallback instead of RGB.
-
#valid_color?(red, green, blue) ⇒ Boolean
Checks whether an RGB triplet is valid.
Constructor Details
#initialize(ansi_fallback, red = nil, green = nil, blue = nil) ⇒ Color
Creates a new color.
560 561 |
# File 'docs/000_a_root.rb', line 560 def initialize(ansi_fallback, red = nil, green = nil, blue = nil) end |
Instance Attribute Details
#ansi_fallback ⇒ Integer
16-color ANSI fallback code.
552 553 554 |
# File 'docs/000_a_root.rb', line 552 def ansi_fallback @ansi_fallback end |
#blue ⇒ Integer?
Blue component (0–255), or nil if fallback-only.
549 550 551 |
# File 'docs/000_a_root.rb', line 549 def blue @blue end |
#green ⇒ Integer?
Green component (0–255), or nil if fallback-only.
546 547 548 |
# File 'docs/000_a_root.rb', line 546 def green @green end |
#red ⇒ Integer?
Red component (0–255), or nil if fallback-only.
543 544 545 |
# File 'docs/000_a_root.rb', line 543 def red @red end |
Instance Method Details
#ansi
Returns the ANSI fallback value.
594 595 |
# File 'docs/000_a_root.rb', line 594 def ansi end |
#ansi=(ansi)
Sets the ANSI fallback value.
591 592 |
# File 'docs/000_a_root.rb', line 591 def ansi=(ansi) end |
#set_color(red, green, blue)
This method returns an undefined value.
Sets the RGB color values.
588 589 |
# File 'docs/000_a_root.rb', line 588 def set_color(red, green, blue) end |
#to_ansi_str ⇒ String
Converts the RGB values into a TrueColor ANSI escape sequence.
574 575 |
# File 'docs/000_a_root.rb', line 574 def to_ansi_str end |
#use_fallback? ⇒ Boolean
Whether this color should use its ANSI fallback instead of RGB.
579 580 |
# File 'docs/000_a_root.rb', line 579 def use_fallback? end |
#valid_color?(red, green, blue) ⇒ Boolean
Checks whether an RGB triplet is valid.
568 569 |
# File 'docs/000_a_root.rb', line 568 def valid_color?(red, green, blue) end |