variations to gets.chomp for user input?!

T

Tim Romberg

What good alternatives to read user input are their in Ruby?! I have
been using the gets.chomp method. But if you wanna pass in a range of
valid options to get read?! Like for example option 1 takes you
somewhere and option 3 takes you some other where etc. I know about the
highline gem but then other people that use this have to install it as
well so I dont want to use that. I was thinking something like defining
a method like this:
attr_reader :eek:ptions
# Pass in array of options
def initialize(options)
@options = options
end

And then calling to it from another method. How can you do that?! I am
really in the beginning of my learning process of Ruby but loving the
language.

Regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top