Class: GitHelper::HighlineCli
- Inherits:
-
Object
- Object
- GitHelper::HighlineCli
- Defined in:
- lib/git_helper/highline_cli.rb
Instance Method Summary collapse
Instance Method Details
#ask(prompt) ⇒ Object
3 4 5 6 7 |
# File 'lib/git_helper/highline_cli.rb', line 3 def ask(prompt) highline_client.ask(prompt) do |conf| conf.readline = true end.to_s end |
#ask_options(prompt, choices) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/git_helper/highline_cli.rb', line 17 def (prompt, choices) = '' choices.each { |choice| << "#{choices.index(choice) + 1}. #{choice}\n" } compiled_prompt = "#{prompt}\n#{.strip}" index = highline_client.ask(compiled_prompt) do |conf| conf.readline = true end.to_i - 1 choices[index] end |
#ask_yes_no(prompt) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/git_helper/highline_cli.rb', line 9 def ask_yes_no(prompt) answer = highline_client.ask(prompt) do |conf| conf.readline = true end.to_s answer.empty? ? true : !!(answer =~ /^y/i) end |