Class: Rich::TerminalTheme
- Inherits:
-
Object
- Object
- Rich::TerminalTheme
- Defined in:
- lib/rich/terminal_theme.rb
Overview
Terminal color theme configuration. Defines the actual RGB values for ANSI colors as rendered by a terminal.
Instance Attribute Summary collapse
-
#ansi_colors ⇒ Array<ColorTriplet>
readonly
16 ANSI colors (indices 0-15).
-
#background ⇒ ColorTriplet
readonly
Default background color.
-
#foreground ⇒ ColorTriplet
readonly
Default foreground color.
Instance Method Summary collapse
-
#==(other) ⇒ Object
(also: #eql?)
Check equality with another theme.
- #hash ⇒ Object
-
#initialize(foreground:, background:, ansi_colors:) ⇒ TerminalTheme
constructor
Create a new terminal theme.
Constructor Details
#initialize(foreground:, background:, ansi_colors:) ⇒ TerminalTheme
Create a new terminal theme
23 24 25 26 27 28 29 30 |
# File 'lib/rich/terminal_theme.rb', line 23 def initialize(foreground:, background:, ansi_colors:) raise ArgumentError, "ansi_colors must have exactly 16 colors" unless ansi_colors.length == 16 @foreground = foreground @background = background @ansi_colors = ansi_colors.freeze freeze end |
Instance Attribute Details
#ansi_colors ⇒ Array<ColorTriplet> (readonly)
Returns 16 ANSI colors (indices 0-15).
17 18 19 |
# File 'lib/rich/terminal_theme.rb', line 17 def ansi_colors @ansi_colors end |
#background ⇒ ColorTriplet (readonly)
Returns Default background color.
14 15 16 |
# File 'lib/rich/terminal_theme.rb', line 14 def background @background end |
#foreground ⇒ ColorTriplet (readonly)
Returns Default foreground color.
11 12 13 |
# File 'lib/rich/terminal_theme.rb', line 11 def foreground @foreground end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
Check equality with another theme
33 34 35 36 37 38 39 |
# File 'lib/rich/terminal_theme.rb', line 33 def ==(other) return false unless other.is_a?(TerminalTheme) @foreground == other.foreground && @background == other.background && @ansi_colors == other.ansi_colors end |
#hash ⇒ Object
43 44 45 |
# File 'lib/rich/terminal_theme.rb', line 43 def hash [@foreground, @background, @ansi_colors].hash end |