I need some help with OptionsParser


#1

Hey all,

I must be doing something wrong here. Im calling the following file
this way:
ruby script.rb -s 1234
or
ruby script.rb -s1111

#Code snip
require ‘optparse’
opts = OptionParser.new
opts.on("-s", “–size VAL”, Integer) do |val|
puts “-s #{val}”
puts val
end

But…no matter what I do, I don’t get any values out. I must be doing
something wrong??

Help!

THanks all,
Brian


#2

On 3/19/06, Brian C. removed_email_address@domain.invalid wrote:

puts “-s #{val}”
puts val
end

But…no matter what I do, I don’t get any values out. I must be doing
something wrong??

After you set up your parser, you need to tell it to do something.

opts.parse(ARGV)

– James