From ef860a8eee9274a8e61d2388414351664583b048 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Mon, 21 Jan 2013 21:44:16 -0500 Subject: [PATCH] internally convert nargs to a range if it was a Fixnum for processing --- lib/yawpa.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/yawpa.rb b/lib/yawpa.rb index 843e38f..6507372 100644 --- a/lib/yawpa.rb +++ b/lib/yawpa.rb @@ -36,21 +36,21 @@ module Yawpa nargs = opt_config[:nargs] || 0 if nargs == 0 opts[param_key] = true - elsif nargs.class == Fixnum + else + nargs = (nargs..nargs) if nargs.class == Fixnum opts[param_key] = [] opts[param_key] << val if val - if opts[param_key].length < nargs - gathered = _gather(i + 1, nargs - opts[param_key].length, params) + if opts[param_key].length < nargs.last + gathered = _gather(i + 1, nargs.last - opts[param_key].length, params) i += gathered.length opts[param_key] += gathered - if opts[param_key].length < nargs + if opts[param_key].length < nargs.first raise InvalidArgumentsException.new("Not enough arguments supplied for option '#{param_name}'") end end if opts[param_key].length == 1 opts[param_key] = opts[param_key].first end - elsif nargs.class == Range end end else