summaryrefslogtreecommitdiff
path: root/lib/slop.rb
diff options
context:
space:
mode:
authorLee Jarvis <ljjarvis@gmail.com>2013-06-16 17:55:46 +0100
committerLee Jarvis <ljjarvis@gmail.com>2013-06-17 10:10:48 +0100
commit2d2634992f47ddb56a95f7b3de48effc27585937 (patch)
tree4a500b3e0e91c3598abe924f08cdd442ff051e32 /lib/slop.rb
parent8f0845514dd28f96faaba8b81c72fb7198d1ea3d (diff)
downloadslop-2d2634992f47ddb56a95f7b3de48effc27585937.tar.gz
clean up extract_short_flag
Diffstat (limited to 'lib/slop.rb')
-rw-r--r--lib/slop.rb17
1 files changed, 4 insertions, 13 deletions
diff --git a/lib/slop.rb b/lib/slop.rb
index f217cdc..eb41e2a 100644
--- a/lib/slop.rb
+++ b/lib/slop.rb
@@ -637,21 +637,12 @@ class Slop
Option.new(self, short, long, desc, config, &block)
end
- # Extract the short flag from an item.
- #
- # objects - The Array of objects passed from #build_option.
- # config - The Hash of configuration options built in #build_option.
def extract_short_flag(objects, config)
- flag = clean(objects.first)
-
- if flag.size == 2 && flag.end_with?('=')
- config[:argument] ||= true
- flag.chop!
- end
-
- if flag.size == 1
+ flag = objects[0].to_s
+ if flag =~ /\A-?\w=?\z/
+ config[:argument] ||= flag.end_with?('=')
objects.shift
- flag
+ flag.delete('-=')
end
end