Sha256: bd3c3d5cc28bba04591fbc688e19fff8a354c6ae3b466a6ef9891e81b1f45dca

Contents?: true

Size: 702 Bytes

Versions: 1

Compression:

Stored size: 702 Bytes

Contents

module ArgsParser
  class Parser

    def parse_style_default(argv)
      k = nil
      is_key = /^-+([^-\s]+)$/
      argv.each_with_index do |arg, index|
        unless k
          if arg =~ is_key
            k = arg.scan(is_key)[0][0].strip.to_sym
            k = aliases[k]  if aliases[k]
          else
            @argv.push arg
          end
        else
          if arg =~ is_key
            params[k][:value] = true
            k = arg.scan(is_key)[0][0].strip.to_sym
            k = aliases[k]  if aliases[k]
          else
            params[k][:value] = arg
            k = nil
          end
        end
      end
      if k
        params[k][:value] = true
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
args_parser-0.2.0 lib/args_parser/styles/default.rb