lib/rake/toolkit_program/command_option_parser.rb
##
# Constrain the number of positional arguments
#
# This is a declarative way of expressing how many positional (i.e.
# non-option) arguments should be accepted by the command.  The
# #=== (i.e. "case match") method of +cardinality_test+ is used to test
# the length of the positional argument Array, raising
# Rake::ToolkitProgram::WrongArgumentCount if #=== returns false.
#
# A special case exists when +cardinality_test+ is a Symbol: because
# a Symbol could never match an Integer, Symbol#to_proc is called to
# create a useful test.
#
# *NOTE* It is worth attention that Proc#=== is an alias for Proc#call,
# so the operator argument is passed to the Proc.  This enables arbitrary
# computation for the validity of the positional argument count,
# syntactically aided by the "stabby-lambda" notation.
#
# While this gem will do its best to explain the argument cardinality,
# +explanation+ provides an opportunity to explicitly provide a 
# sentence to be included in the help about the allowed cardinality
# (i.e. count) of positional arguments.
#
Constrain the number of positional arguments
This is a declarative way of expressing how many positional  arguments should be accepted by the command.  The
method of +cardinality_test+ is used to test
the length of the positional argument Array, raising
Rake::ToolkitProgram::WrongArgumentCount if #=== returns false.

A special case exists when +cardinality_test+ is a Symbol: because
a Symbol could never match an Integer, Symbol#to_proc is called to
create a useful test.

NOTE* It is worth attention that Proc#=== is an alias for Proc#call,
so the operator argument is passed to the Proc.  This enables arbitrary
computation for the validity of the positional argument count,
syntactically aided by the "stabby-lambda" notation.

While this gem will do its best to explain the argument cardinality,
+explanation+ provides an opportunity to explicitly provide a
sentence to be included in the help about the allowed cardinality
of positional arguments.
Constrain the number of positional arguments This is a declarative way of expressing how many positional arguments should be accepted by the command . The method of + cardinality_test + is used to test the length of the positional argument Array raising Rake :: ToolkitProgram :: WrongArgumentCount if # === returns false . A special case exists when + cardinality_test + is a Symbol : because a Symbol could never match an Integer Symbol#to_proc is called to create a useful test . NOTE * It is worth attention that Proc# === is an alias for Proc#call so the operator argument is passed to the Proc . This enables arbitrary computation for the validity of the positional argument count syntactically aided by the " stabby - lambda " notation . While this gem will do its best to explain the argument cardinality + explanation + provides an opportunity to explicitly provide a sentence to be included in the help about the allowed cardinality of positional arguments .
def expect_positional_cardinality(cardinality_test, explanation=nil)
        @positional_cardinality_explanation = explanation
        if cardinality_test.kind_of?(Symbol)
          cardinality_test.to_s.tap do |test_name|
            if explanation.nil? && test_name.end_with?('?')
              @positional_cardinality_explanation = (
                "Positional argument count must be #{test_name[0..-2].gsub('_', ' ')}."
              )
            end
          end
          cardinality_test = cardinality_test.to_proc
        end
        @positional_cardinality_test = cardinality_test
      end
def expect_positional_cardinality ( cardinality_test , explanation = nil ) @positional_cardinality_explanation = explanation if cardinality_test . kind_of? ( Symbol ) cardinality_test . to_s . tap do | test_name | if explanation . nil? && test_name . end_with? ( '?' ) @positional_cardinality_explanation = ( "Positional argument count must be #{test_name[0..-2].gsub('_', ' ')}." ) end end cardinality_test = cardinality_test . to_proc end @positional_cardinality_test = cardinality_test end
Constrain the number of positional arguments
This is a declarative way of expressing how many positional (i.e.
Constrain the number of positional arguments This is a declarative way of expressing how many positional ( i . e .
cardinality_test
<not_specific>
explanation
<not_specific>