Sha256: 1966533de10bc5245af61bcc3579f5c28ec99145e015c048108c1602436e4f4e

Contents?: true

Size: 534 Bytes

Versions: 22

Compression:

Stored size: 534 Bytes

Contents

# frozen_string_literal: true
require 'optparse'

class OptionParser
  # :call-seq:
  #   define_by_keywords(options, method, **params)
  #
  # :include: ../../doc/optparse/creates_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

22 entries across 22 versions & 1 rubygems

Version Path
opal-1.8.3.rc1 stdlib/optparse/kwargs.rb
opal-1.8.2 stdlib/optparse/kwargs.rb
opal-1.8.1 stdlib/optparse/kwargs.rb
opal-1.8.0 stdlib/optparse/kwargs.rb
opal-1.8.0.beta1 stdlib/optparse/kwargs.rb
opal-1.7.4 stdlib/optparse/kwargs.rb
opal-1.8.0.alpha1 stdlib/optparse/kwargs.rb
opal-1.7.3 stdlib/optparse/kwargs.rb
opal-1.7.2 stdlib/optparse/kwargs.rb
opal-1.7.1 stdlib/optparse/kwargs.rb
opal-1.7.0 stdlib/optparse/kwargs.rb
opal-1.7.0.rc1 stdlib/optparse/kwargs.rb
opal-1.6.1 stdlib/optparse/kwargs.rb
opal-1.6.0 stdlib/optparse/kwargs.rb
opal-1.6.0.rc1 stdlib/optparse/kwargs.rb
opal-1.6.0.alpha1 stdlib/optparse/kwargs.rb
opal-1.5.1 stdlib/optparse/kwargs.rb
opal-1.5.0 stdlib/optparse/kwargs.rb
opal-1.5.0.rc1 stdlib/optparse/kwargs.rb
opal-1.4.1 stdlib/optparse/kwargs.rb