Question

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.

Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top