Class: Thor::Shell::HTML

Inherits:
Basic show all
Defined in:
lib/bundler/vendor/thor/shell/html.rb

Overview

Inherit from Thor::Shell::Basic and add set_color behavior. Check Thor::Shell::Basic to see all available methods.

Constant Summary collapse

BOLD =

The start of an HTML bold sequence.

"<strong>"
END_BOLD =

The end of an HTML bold sequence.

"</strong>"
CLEAR =

Embed in a String to clear previous color selection.

"</span>"
BLACK =

Set the terminal’s foreground HTML color to black.

'<span style="color: black;">'
RED =

Set the terminal’s foreground HTML color to red.

'<span style="color: red;">'
GREEN =

Set the terminal’s foreground HTML color to green.

'<span style="color: green;">'
YELLOW =

Set the terminal’s foreground HTML color to yellow.

'<span style="color: yellow;">'
BLUE =

Set the terminal’s foreground HTML color to blue.

'<span style="color: blue;">'
MAGENTA =

Set the terminal’s foreground HTML color to magenta.

'<span style="color: magenta;">'
CYAN =

Set the terminal’s foreground HTML color to cyan.

'<span style="color: cyan;">'
WHITE =

Set the terminal’s foreground HTML color to white.

'<span style="color: white;">'
ON_BLACK =

Set the terminal’s background HTML color to black.

'<span style="background-color: black">'
ON_RED =

Set the terminal’s background HTML color to red.

'<span style="background-color: red">'
ON_GREEN =

Set the terminal’s background HTML color to green.

'<span style="background-color: green">'
ON_YELLOW =

Set the terminal’s background HTML color to yellow.

'<span style="background-color: yellow">'
ON_BLUE =

Set the terminal’s background HTML color to blue.

'<span style="background-color: blue">'
ON_MAGENTA =

Set the terminal’s background HTML color to magenta.

'<span style="background-color: magenta">'
ON_CYAN =

Set the terminal’s background HTML color to cyan.

'<span style="background-color: cyan">'
ON_WHITE =

Set the terminal’s background HTML color to white.

'<span style="background-color: white">'

Instance Attribute Summary

Attributes inherited from Basic

#base, #padding

Instance Method Summary collapse

Methods inherited from Basic

#error, #file_collision, #initialize, #mute, #mute?, #no?, #print_table, #print_wrapped, #say, #say_status, #yes?

Constructor Details

This class inherits a constructor from Thor::Shell::Basic

Instance Method Details

#ask(statement, color = nil) ⇒ Object

Ask something to the user and receives a response.

Example

ask(“What is your name?”)

TODO: Implement #ask for Thor::Shell::HTML

Raises:

  • (NotImplementedError)


68
69
70
# File 'lib/bundler/vendor/thor/shell/html.rb', line 68

def ask(statement, color=nil)
  raise NotImplementedError, "Implement #ask for Thor::Shell::HTML"
end

#set_color(string, color, bold = false) ⇒ 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.



56
57
58
59
60
# File 'lib/bundler/vendor/thor/shell/html.rb', line 56

def set_color(string, color, bold=false)
  color = self.class.const_get(color.to_s.upcase) if color.is_a?(Symbol)
  bold, end_bold = bold ? [BOLD, END_BOLD] : ['', '']
  "#{bold}#{color}#{string}#{CLEAR}#{end_bold}"
end