class Bundler::Thor::Shell::HTML
Inherit from Bundler::Thor::Shell::Basic
and add set_color
behavior. Check Bundler::Thor::Shell::Basic
to see all available methods.
Constants
- BLACK
- BLUE
- BOLD
The start of an
HTML
bold sequence.- CYAN
- GREEN
- MAGENTA
- ON_BLACK
- ON_BLUE
- ON_CYAN
- ON_GREEN
- ON_MAGENTA
- ON_RED
- ON_WHITE
- ON_YELLOW
- RED
- WHITE
- YELLOW
Public Instance Methods
ask(statement, color = nil)
click to toggle source
Ask something to the user and receives a response.
Example¶ ↑
ask(“What is your name?”)
TODO: Implement ask
for Bundler::Thor::Shell::HTML
# File lib/bundler/vendor/thor/lib/thor/shell/html.rb, line 70 def ask(statement, color = nil) raise NotImplementedError, "Implement #ask for Bundler::Thor::Shell::HTML" end
set_color(string, *colors)
click to toggle source
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
.
# 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
Protected Instance Methods
can_display_colors?()
click to toggle source
# File lib/bundler/vendor/thor/lib/thor/shell/html.rb, line 76 def can_display_colors? true end