Skip to content

Instantly share code, notes, and snippets.

@flakyfilibuster
Created October 22, 2012 18:55
Show Gist options
  • Save flakyfilibuster/3933375 to your computer and use it in GitHub Desktop.
Save flakyfilibuster/3933375 to your computer and use it in GitHub Desktop.
OptionParser Example
require 'optparse'
options = {date: false, sort: false, ddate: false, tag: false, prio: false}
optparse = OptionParser.new do|opts|
opts.on("--date") do
options[:date] = true
end
opts.on('--sort') do
options[:sort] = true
end
opts.on("--ddate") do
options[:ddate] = true
end
opts.on('--tag') do
options[:tag] = true
end
opts.on('--prio') do
options[:prio] = true
end
end
optparse.parse!
@flakyfilibuster
Copy link
Author

If you have suggestions how to optimize the code or if you notice any glaring errors please contact me :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment