Hello,
I’m writing a small script to be handled with optparser. I’ve read the
documentation everything worked fine at first, then suddenly it stopped
accepting my flag parameters. The relevant part of the code is here:
class Morula
attr_accessor :database, :tableid
def initialize(database, tableid)
@database = database
@tableid = tableid
[…]
end
end
options = {}
optparse = OptionParser.new do |opts|
[…]
opts.on(’-d’, ‘–database’, ‘comments go here’) do |x|
options[:database] = x
end
[…]
end
[…]
if options[:database] == nil
db = db_default
else
db = options[:database].to_s
end
[…]
puts options[:database] # gives true instead of ‘x’
Is there something obvious I’m missing? I tried also adding ‘String’:
[…]
opts.on(’-d’, ‘–database’, String, ‘comments go here’) do |x|
options[:database] = x
end
[…]
Regards,
Panagiotis A.