diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/slop/parser.rb | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/lib/slop/parser.rb b/lib/slop/parser.rb index d1410a3..553c2ff 100644 --- a/lib/slop/parser.rb +++ b/lib/slop/parser.rb @@ -62,8 +62,9 @@ module Slop # arguments (plus the arg if necessary) # delete argument first so that it doesn't mess up the index if opt.expects_argument? - index = arg_index(flag, arg) - arguments.delete_at(index) if !index.nil? + arguments.each_with_index do |argument, i| + arguments.delete_at(i + 1) if argument == flag + end end arguments.delete(flag) end @@ -120,16 +121,5 @@ module Slop def matching_option(flag) options.find { |o| o.flags.include?(flag) } end - - # Returns the index of the argument corresponding to a flag. - def arg_index(flag, arg) - flag_index = arguments.index(flag) - return nil if flag_index.nil? - - arg_index = arguments[flag_index..-1].index(arg) - return nil if arg_index.nil? - - flag_index + arg_index - end end end |