Sha256: af653455ad8a5d88e2ff24d43cab56880c04aabfe58338ecd8152dccf6c1e4df

Contents?: true

Size: 632 Bytes

Versions: 1

Compression:

Stored size: 632 Bytes

Contents

module Tcl
  module Ruby
    class OptionParser
      # options_format
      # array of string
      # xxxx or xxxx?
      # ? indicates that value has one argument
      def self.parse(options, args)
        ops = options.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
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tcl-ruby-0.1.1 lib/tcl/ruby/option_parser.rb