Class: Charming::UI::AdaptiveColor
- Inherits:
-
Object
- Object
- Charming::UI::AdaptiveColor
- Defined in:
- lib/charming/presentation/ui/adaptive_color.rb
Overview
AdaptiveColor is a color value that resolves to its light or dark variant
at render time, based on the detected terminal background. Build one with
UI.adaptive(light:, dark:) and use it anywhere a color is accepted.
Instance Method Summary collapse
-
#initialize(light:, dark:) ⇒ AdaptiveColor
constructor
A new instance of AdaptiveColor.
-
#resolve ⇒ Object
The variant readable on the current terminal background.
Constructor Details
#initialize(light:, dark:) ⇒ AdaptiveColor
Returns a new instance of AdaptiveColor.
9 10 11 12 |
# File 'lib/charming/presentation/ui/adaptive_color.rb', line 9 def initialize(light:, dark:) @light = light @dark = dark end |
Instance Method Details
#resolve ⇒ Object
The variant readable on the current terminal background.
15 16 17 |
# File 'lib/charming/presentation/ui/adaptive_color.rb', line 15 def resolve Background.dark? ? @dark : @light end |