variations to gets.chomp for user input?!

Discussion in 'Ruby' started by Tim Romberg, Sep 12, 2010.

  1. Tim Romberg

    Tim Romberg Guest

    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
    --
    Posted via http://www.ruby-forum.com/.
    Tim Romberg, Sep 12, 2010
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    6
    Views:
    119
    Guillaume Benny
    Mar 29, 2006
  2. Guest

    Newbie Question (gets.chomp)

    Guest, Jul 1, 2007, in forum: Ruby
    Replies:
    1
    Views:
    102
    Axel Etzold
    Jul 1, 2007
  3. Vister Gade

    gets.chomp....... not function

    Vister Gade, Apr 14, 2008, in forum: Ruby
    Replies:
    6
    Views:
    115
    Marc Heiler
    Apr 14, 2008
  4. Durga B.
    Replies:
    0
    Views:
    126
    Durga B.
    Nov 29, 2010
  5. martin
    Replies:
    3
    Views:
    179
    Joe Smith
    Apr 15, 2006
Loading...

Share This Page