You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
require 'rubygems'
require 'highline/import'
pass = ask("Enter your password: ") do |q|
q.echo = '*'
q.verify_match = true
q.gather = {"Enter a password" => '',
"Please type it again for verification" => ''}
end
response from terminal:
Enter your password: ****
// I expected: "Enter a password: "
Enter your password: ****
// I expected: "Please type it again for verification: "
Your password is now asdf!
I feel like I might be missing something in terms of usage that isn't correctly illustrated by the example.
The text was updated successfully, but these errors were encountered:
Mmmm.. That's what I expected. I've had a look at that already.
"Optionally gather can be set to a Hash. In this case, the question will be asked once for each key and the answers will be returned in a Hash, mapped by key. The @key variable is set before each question is evaluated, so you can use it in your question."
And the code below makes me think that I should ask() differently if I'm using a hash. Though it seems that it's locked into asking the original question, however many times.
# /lib/highline.rb
# lines: 783 - 790
when Hash
@answers = { }
@gather.keys.sort.each do |key|
@question = original_question
@key = key
@answers[key] = ask(@question)
end
Is it possible that you could give me a super simple example of gather working with a hash, I'm not familiar with highline yet and the RDoc entry didn't lead me to a working solution. I'm sure it's something simple. Thank you.
Cut down code from examples/repeat_entry.rb
response from terminal:
I feel like I might be missing something in terms of usage that isn't correctly illustrated by the example.
The text was updated successfully, but these errors were encountered: