Skip to content

Instantly share code, notes, and snippets.

@tatey
Forked from ThisIsMissEm/gist:325082
Created March 8, 2010 11:37
Show Gist options
  • Save tatey/325083 to your computer and use it in GitHub Desktop.
Save tatey/325083 to your computer and use it in GitHub Desktop.
def get_options(args)
args.inject({}) do |args, arg|
if arg =~ /^--(\S+)$/
key, value = $1.split('=')
args[key] = value.nil? || value
elsif arg =~ /^-(no-?)(\S+)/
if $1 == "no-"
args[$2] = false
else
args[$1] = true
end
end
args
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment