Class: DevSuite::Utils::Color::Strategy::Theme

Inherits:
Base show all
Defined in:
lib/dev_suite/utils/color/strategy/theme.rb

Instance Method Summary collapse

Methods inherited from DevSuite::Utils::Construct::Component::Base

component_key

Instance Method Details

#colorize(text, color: :default) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/dev_suite/utils/color/strategy/theme.rb', line 8

def colorize(text, color: :default)
  unless palette.colors.key?(color)
    raise ArgumentError, "Invalid color key"
  end

  color_code = palette.colors[color]

  unless valid_color_code?(color_code)
    raise ArgumentError, "Invalid color code"
  end

  "\e[#{color_code}m#{text}\e[0m"
end