Module: Grably::ShellColors

Defined in:
lib/grably/core/colors.rb

Overview

Contains escape symbols for colors representation in *nix shells. If used adds coloring methods to String object. This module is intendet to be included in String class

Constant Summary collapse

COLOR_RESET =

Color code sequence which resets colors to default state. Which is normal (0), default (39) and bg_default (49)

color(:normal, :default, :bg_default)

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.color(*args) ⇒ String

Generates color codes sequence to create color effect

Parameters:

  • args (String | Symbol)

    color settigns

Returns:

  • (String)

    color control sequence



41
42
43
44
# File 'lib/grably/core/colors.rb', line 41

def color(*args)
  codes = args.map { |a| COLOR_CODES[a.to_sym] }.compact
  "\e[#{codes.join(';')}m"
end

Instance Method Details

#color(*args) ⇒ Object



51
52
53
# File 'lib/grably/core/colors.rb', line 51

def color(*args)
  Grably::ShellColors.color(*args)
end