Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Gem::StreamUI#ask
ask(question)
lib/rubygems/user_interaction.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/lib/rubygems/user_interaction.rb, line 281
def ask(question)
return nil unless tty?
@outs.print(question + " ")
@outs.flush
result = @ins.gets
result&.chomp!
result
end
Ask a question. Returns an answer if connected to a tty, nil otherwise.
See also
#alert_warning
#ask_for_password
#alert_error
#ask_yes_no
also in
4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0