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.
282 283 284 |
# File 'lib/bootic_cli/commands/themes.rb', line 282 def initialize(shell = Thor::Shell::Color.new) @shell = shell end |
Instance Method Details
#highlight(str, color = :bold) ⇒ Object
318 319 320 |
# File 'lib/bootic_cli/commands/themes.rb', line 318 def highlight(str, color = :bold) shell.set_color str, color end |
#notice(str) ⇒ Object
309 310 311 312 |
# File 'lib/bootic_cli/commands/themes.rb', line 309 def notice(str) parts = [" --->", str] puts highlight parts.join(' ') end |
#pause(string, color = nil) ⇒ Object
300 301 302 303 304 305 306 307 |
# File 'lib/bootic_cli/commands/themes.rb', line 300 def pause(string, color = nil) begin input = shell.ask(string, color) rescue Interrupt say "\nCtrl-C received. Bailing out!", :magenta abort end end |
#say(str, color = nil) ⇒ Object
314 315 316 |
# File 'lib/bootic_cli/commands/themes.rb', line 314 def say(str, color = nil) shell.say str, color end |
#yes_or_no?(question, default_answer) ⇒ Boolean
286 287 288 289 290 291 292 293 294 295 296 297 298 |
# File 'lib/bootic_cli/commands/themes.rb', line 286 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 |