Sha256: a618c59bc0489ffe3d4c1ceeed95bb261a8842b3dfb3816fa1955757abe68e4f

Contents?: true

Size: 546 Bytes

Versions: 1

Compression:

Stored size: 546 Bytes

Contents

# frozen_string_literal: true
require_relative 'option_parser'

class 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.1.1 lib/cmd-optparse/kwargs.rb