Class: BooticCli::Commands::Themes::Prompt
- Inherits:
-
Object
- Object
- BooticCli::Commands::Themes::Prompt
- Defined in:
- lib/bootic_cli/commands/themes.rb
Instance Method Summary collapse
- #highlight(str, color = :bold) ⇒ Object
-
#initialize(shell = Thor::Shell::Color.new) ⇒ Prompt
constructor
A new instance of Prompt.
- #notice(str) ⇒ Object
- #say(str, color = nil) ⇒ Object
- #yes_or_no?(question, default_answer) ⇒ Boolean
Constructor Details
#initialize(shell = Thor::Shell::Color.new) ⇒ Prompt
Returns a new instance of Prompt.
190 191 192 |
# File 'lib/bootic_cli/commands/themes.rb', line 190 def initialize(shell = Thor::Shell::Color.new) @shell = shell end |
Instance Method Details
#highlight(str, color = :bold) ⇒ Object
217 218 219 |
# File 'lib/bootic_cli/commands/themes.rb', line 217 def highlight(str, color = :bold) shell.set_color str, color end |
#notice(str) ⇒ Object
208 209 210 211 |
# File 'lib/bootic_cli/commands/themes.rb', line 208 def notice(str) parts = [" --->", str] puts highlight parts.join(' ') end |
#say(str, color = nil) ⇒ Object
213 214 215 |
# File 'lib/bootic_cli/commands/themes.rb', line 213 def say(str, color = nil) shell.say str, color end |
#yes_or_no?(question, default_answer) ⇒ Boolean
194 195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/bootic_cli/commands/themes.rb', line 194 def yes_or_no?(question, default_answer) default_char = default_answer ? 'y' : 'n' begin input = shell.ask("#{question} [#{default_char}]").strip rescue Interrupt say "\nCtrl-C received. Bailing out!", :magenta abort end return default_answer if input == '' || input.downcase == default_char !default_answer end |