Class: Tcl::Ruby::OptionParser
- Inherits:
-
Object
- Object
- Tcl::Ruby::OptionParser
- Defined in:
- lib/tcl/ruby/option_parser.rb
Class Method Summary collapse
-
.parse(options, args) ⇒ Object
options_format array of string xxxx or xxxx? ? indicates that value has one argument.
Class Method Details
.parse(options, args) ⇒ Object
options_format array of string xxxx or xxxx? ? indicates that value has one argument
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/tcl/ruby/option_parser.rb', line 8 def self.parse(, args) ops = .map do |e| v = e.sub(/\?/, '') ["-#{v}", v, e[-1] == '?'] end ret = {} loop do r = ops.each do |o| next unless args[0] == o[0] args.shift ret[o[1]] = true ret[o[1]] = args.shift if o[2] break false end break if r end ret end |