diff options
author | Lee Jarvis <ljjarvis@gmail.com> | 2014-11-20 07:39:11 +0000 |
---|---|---|
committer | Lee Jarvis <ljjarvis@gmail.com> | 2014-11-20 07:39:11 +0000 |
commit | 63b0a7bd3e7b4df73dbf5a6c5d3ddece7dc13e97 (patch) | |
tree | 4f3a71fcc33b6aa4ca07805a59bd57625971047a /lib/slop/parser.rb | |
parent | f4611c9c7c07cae1fff3c9db81d96994cf834dab (diff) | |
download | slop-63b0a7bd3e7b4df73dbf5a6c5d3ddece7dc13e97.tar.gz |
Simplify Parser used_options
Diffstat (limited to 'lib/slop/parser.rb')
-rw-r--r-- | lib/slop/parser.rb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/slop/parser.rb b/lib/slop/parser.rb index 148e1d1..6e17d48 100644 --- a/lib/slop/parser.rb +++ b/lib/slop/parser.rb @@ -1,6 +1,6 @@ module Slop class Parser - attr_reader :options, :used_options, :config + attr_reader :options, :config def initialize(options, **config) @options = options @@ -12,7 +12,6 @@ module Slop # Reset the parser, useful to use the same instance # to parse a second time without duplicating state. def reset - @used_options = [] @options.each(&:reset) self end @@ -36,6 +35,10 @@ module Slop end end + def used_options + options.select { |o| o.count > 0 } + end + def unused_options options.to_a - used_options end @@ -44,7 +47,6 @@ module Slop # We've found an option, process it def process(option, arg) - used_options << option option.ensure_call(arg) end |