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
- #pause(string, color = nil) ⇒ 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.
336 337 338 |
# File 'lib/bootic_cli/commands/themes.rb', line 336 def initialize(shell = Thor::Shell::Color.new) @shell = shell end |
Instance Method Details
#highlight(str, color = :bold) ⇒ Object
372 373 374 |
# File 'lib/bootic_cli/commands/themes.rb', line 372 def highlight(str, color = :bold) shell.set_color str, color end |
#notice(str) ⇒ Object
363 364 365 366 |
# File 'lib/bootic_cli/commands/themes.rb', line 363 def notice(str) parts = [" --->", str] puts highlight parts.join(' ') end |
#pause(string, color = nil) ⇒ Object
354 355 356 357 358 359 360 361 |
# File 'lib/bootic_cli/commands/themes.rb', line 354 def pause(string, color = nil) begin input = shell.ask(string, color) rescue Interrupt say "\nCtrl-C received. Bailing out!", :magenta exit end end |
#say(str, color = nil) ⇒ Object
368 369 370 |
# File 'lib/bootic_cli/commands/themes.rb', line 368 def say(str, color = nil) shell.say str, color end |
#yes_or_no?(question, default_answer) ⇒ Boolean
340 341 342 343 344 345 346 347 348 349 350 351 352 |
# File 'lib/bootic_cli/commands/themes.rb', line 340 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 exit end return default_answer if input == '' || input.downcase == default_char !default_answer end |