summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLee Jarvis <lee@jarvis.co>2011-03-16 19:14:15 +0000
committerLee Jarvis <lee@jarvis.co>2011-03-16 19:14:15 +0000
commit1d63ecf41df0aacb7023816c07d3643f0f4b3f41 (patch)
treeceab9e14e64b5bb7e9f1d1a7c2574e601c4e8a74
parente7819fb5d284a46c813b3dbca77f376c8f459a4d (diff)
downloadslop-1d63ecf41df0aacb7023816c07d3643f0f4b3f41.tar.gz
simplify parsing operation
-rw-r--r--lib/slop.rb6
-rw-r--r--lib/slop/option.rb4
2 files changed, 3 insertions, 7 deletions
diff --git a/lib/slop.rb b/lib/slop.rb
index 40f5d55..2589dfb 100644
--- a/lib/slop.rb
+++ b/lib/slop.rb
@@ -92,11 +92,7 @@ private
items.each do |item|
flag = item.to_s.sub(/^--?/, '')
- if flag.length == 1
- option = find { |option| option.short_flag == flag }
- else
- option = find { |option| option.long_flag == flag }
- end
+ option = @options[flag]
if option
option.argument_value = true
diff --git a/lib/slop/option.rb b/lib/slop/option.rb
index 2417e9e..eb20527 100644
--- a/lib/slop/option.rb
+++ b/lib/slop/option.rb
@@ -8,8 +8,8 @@ class Slop
def [](item)
item = item.to_s
- if item =~ /^\d+/
- super
+ if item =~ /^\d+$/
+ slice(item.to_i)
else
find do |option|
option.short_flag == item || option.long_flag == item