Skip to content

Instantly share code, notes, and snippets.

@ThisIsMissEm
Forked from tatey/gist:325073
Created March 8, 2010 11:36
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/325082 to your computer and use it in GitHub Desktop.
Save ThisIsMissEm/325082 to your computer and use it in GitHub Desktop.
def get_options(args)
options = {}
args.each {|arg|
arg.scan(/^(?:(?:|-)(?:-(no)?)?)-(\w+)(?:=(\w+))?$/) {|bool,key,value|
key = "no-"+key if !value.nil? && !bool.nil?
options[key] = value.nil? && bool.nil? || (value || bool.nil?)
}
}
options
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment