S
Srijayanth Sridhar
[Note: parts of this message were removed to make it a legal post.]
Hello,
I am using OptionParser and one of the nifty things it has is multi line
descriptions for each option. I have a particularly long list of valid
arguments for a valid option, for instance cities=[London,Paris,NY......].
If printed in a single line it runs over and looks ugly. My hack so far is:
def pretty_print_list list,num=5
a=[]
(0...list.size).step(num) { |i| a << (list[i...i+num]).join(',') }
a
end
This returns a list of strings which I pass as *list to the OptionParser .on
method as follows:
arg.on("--city [CITY]",cities,*list) { |o| options.city=o }
The hack works fine, but on a broader subject, is there a nice easy way of
grouping arrays? In python Range accepts a step value which is quite
awesome...
Thanks,
Jayanth
Hello,
I am using OptionParser and one of the nifty things it has is multi line
descriptions for each option. I have a particularly long list of valid
arguments for a valid option, for instance cities=[London,Paris,NY......].
If printed in a single line it runs over and looks ugly. My hack so far is:
def pretty_print_list list,num=5
a=[]
(0...list.size).step(num) { |i| a << (list[i...i+num]).join(',') }
a
end
This returns a list of strings which I pass as *list to the OptionParser .on
method as follows:
arg.on("--city [CITY]",cities,*list) { |o| options.city=o }
The hack works fine, but on a broader subject, is there a nice easy way of
grouping arrays? In python Range accepts a step value which is quite
awesome...
Thanks,
Jayanth