aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJack Nagel2013-05-20 22:34:54 -0500
committerJack Nagel2013-05-20 22:34:54 -0500
commit29590171230e4a60d0aa43480825de4b131753be (patch)
treede8b5cd83b78e07033d3418ec8fbebfc4ffbab53 /Library
parente830796fb7cc5805ec73391e9b1d0008fbce19fc (diff)
downloadhomebrew-29590171230e4a60d0aa43480825de4b131753be.tar.bz2
Simplify implementation of ARGV.flag? and .switch?
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/extend/ARGV.rb13
1 files changed, 4 insertions, 9 deletions
diff --git a/Library/Homebrew/extend/ARGV.rb b/Library/Homebrew/extend/ARGV.rb
index 32acee7da..b71d5f103 100644
--- a/Library/Homebrew/extend/ARGV.rb
+++ b/Library/Homebrew/extend/ARGV.rb
@@ -135,22 +135,17 @@ module HomebrewArgvExtension
end
def flag? flag
- options_only.each do |arg|
- return true if arg == flag
- next if arg[1..1] == '-'
- return true if arg.include? flag[2..2]
+ options_only.any? do |arg|
+ arg == flag || arg[1..1] != '-' && arg.include?(flag[2..2])
end
- return false
end
# eg. `foo -ns -i --bar` has three switches, n, s and i
def switch? switch_character
return false if switch_character.length > 1
- options_only.each do |arg|
- next if arg[1..1] == '-'
- return true if arg.include? switch_character
+ options_only.any? do |arg|
+ arg[1..1] != '-' && arg.include?(switch_character)
end
- return false
end
def usage