Sha256: 53931450b9ba3e5b064d2e64326f0eef6ddd5d8af11fbb9de54336dacbb85b40

Contents?: true

Size: 518 Bytes

Versions: 1

Compression:

Stored size: 518 Bytes

Contents

# frozen_string_literal: true

class Cmd::OptionParser
  # :call-seq:
  #   define_by_keywords(options, method, **params)
  #
  # :include: ../..option_parserreates_option.rdoc
  #
  def define_by_keywords(options, meth, **opts)
    meth.parameters.each do |type, name|
      case type
      when :key, :keyreq
        op, cl = *(type == :key ? %w"[ ]" : ["", ""])
        define("--#{name}=#{op}#{name.upcase}#{cl}", *opts[name]) do |o|
          options[name] = o
        end
      end
    end
    options
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cmd-optparse.rb-0.5.2 lib/cmd/option_parser/kwargs.rb