Class: BooticCli::Commands::Themes::Prompt

Inherits:
Object
  • Object
show all
Defined in:
lib/bootic_cli/commands/themes.rb

Instance Method Summary collapse

Constructor Details

#initialize(shell = Thor::Shell::Color.new) ⇒ Prompt

Returns a new instance of Prompt.



133
134
135
# File 'lib/bootic_cli/commands/themes.rb', line 133

def initialize(shell = Thor::Shell::Color.new)
  @shell = shell
end

Instance Method Details

#highlight(str, color = :bold) ⇒ Object



153
154
155
# File 'lib/bootic_cli/commands/themes.rb', line 153

def highlight(str, color = :bold)
  shell.set_color str, color
end

#notice(str) ⇒ Object



144
145
146
147
# File 'lib/bootic_cli/commands/themes.rb', line 144

def notice(str)
  parts = [" --->", str]
  puts highlight parts.join(' ')
end

#say(str, color = nil) ⇒ Object



149
150
151
# File 'lib/bootic_cli/commands/themes.rb', line 149

def say(str, color = nil)
  shell.say str, color
end

#yes_or_no?(question, default_answer) ⇒ Boolean

Returns:

  • (Boolean)


137
138
139
140
141
142
# File 'lib/bootic_cli/commands/themes.rb', line 137

def yes_or_no?(question, default_answer)
  default_char = default_answer ? 'y' : 'n'
  input = shell.ask("#{question} [#{default_char}]").strip
  return default_answer if input == '' || input.downcase == default_char
  !default_answer
end