Module: Colorize

Defined in:
lib/galaxy/colorize.rb

Defined Under Namespace

Modules: ANSIColors

Class Method Summary collapse

Class Method Details

.colorize(string, *colors) ⇒ Object



14
15
16
17
18
# File 'lib/galaxy/colorize.rb', line 14

def self.colorize(string, *colors)
  color_string = colors.map { |color| ANSIColors::COLORS[color] }.join

  return "#{color_string}#{string}#{ANSIColors::COLORS[:normal]}"
end

.strip_colors(string) ⇒ Object



20
21
22
# File 'lib/galaxy/colorize.rb', line 20

def self.strip_colors(string)
  string.gsub(/\e\[\d+m/, '')
end