This is my code:
#!/usr/bin/env ruby
# OptionParser
require 'optparse'
options = {}
optparse = OptionParser.new do|opts|
opts.banner = '...'
# This option inputs ...
options[:Lap1] = []
opts.on('-1', '--Lap1 filepath1,width1,height1,a1,first1,last1', String, '...') do|l1|
options[:Lap1] = l1.split(',')
end
end
optparse.parse!
My goal is to have an array of the separate inputs separated by commas. However this code only outputs the first variable $filepath1
.
The output of:
puts(options[:Lap1])
and
puts(options[:Lap1][0]
is just the the first variable filepath1
.
puts(options[:Lap1][1])
is nil
, when it should be the variable width1
.
Any suggestions or potential fixes would be helpful, thank you.