문제

I am trying OptionParser using the complete example on the documentation.

I changed the program to output some random text instead of outputting the options and ARGV.

I was wondering how to actually delay the program when I run the following:

ruby optparse.rb --delay 50 

I expect it to delay 50 seconds before it outputs the text. However, this is not the case, it just outputs the text straight away.

도움이 되었습니까?

해결책

The example code on the page you linked to only shows how to parse the options, it's doesn't take any real actions based on them. There is no code in there that actually delays. You could add it yourself by doing something like:

puts "Sleeping for #{options.delay}..."
sleep options.delay
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top