Sha256: d7de6d68bdeff0113f26c8dc0c6cc0ad982e575122e7c9091385ae7f2f85f082

Contents?: true

Size: 518 Bytes

Versions: 3

Compression:

Stored size: 518 Bytes

Contents

# frozen_string_literal: true

class CLI::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

3 entries across 3 versions & 1 rubygems

Version Path
cli-option_parser.rb-0.6.0 lib/cli/option_parser/kwargs.rb
cli-option_parser.rb-0.5.3 lib/cli/option_parser/kwargs.rb
cli-option_parser.rb-0.5.2 lib/cli/option_parser/kwargs.rb