Method: Bundler::Thor::Shell::HTML#set_color
- Defined in:
- lib/bundler/vendor/thor/lib/thor/shell/html.rb
#set_color(string, *colors) ⇒ Object
Set color by using a string or one of the defined constants. If a third option is set to true, it also adds bold to the string. This is based on Highline implementation and it automatically appends CLEAR to the end of the returned String.
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/bundler/vendor/thor/lib/thor/shell/html.rb', line 51 def set_color(string, *colors) if colors.all? { |color| color.is_a?(Symbol) || color.is_a?(String) } html_colors = colors.map { |color| lookup_color(color) } "<span style=\"#{html_colors.join('; ')};\">#{Bundler::Thor::Util.escape_html(string)}</span>" else color, bold = colors html_color = self.class.const_get(color.to_s.upcase) if color.is_a?(Symbol) styles = [html_color] styles << BOLD if bold "<span style=\"#{styles.join('; ')};\">#{Bundler::Thor::Util.escape_html(string)}</span>" end end |