Skip to content

Instantly share code, notes, and snippets.

@ThisIsMissEm
Created March 8, 2010 10:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ThisIsMissEm/325062 to your computer and use it in GitHub Desktop.
Save ThisIsMissEm/325062 to your computer and use it in GitHub Desktop.
def getOptions(args)
options = {}
args.each{|arg|
if arg[0,2] == "--" && arg.length > 2
key, value = arg[2..-1].split("=")
options[key] = value
elsif arg[0,1] == "-" && arg.length > 1
key = arg[1..-1]
if key =~ /no-/
options[key[3..-1]] = false
else
options[key] = true
end
else
end
}
options
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment