aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/options.rb
diff options
context:
space:
mode:
authorJack Nagel2014-08-13 11:09:57 -0500
committerJack Nagel2014-08-13 11:09:57 -0500
commit096152214a6cf6cf6a50270f93b747568beb748b (patch)
treee163d5e6b45c134bb56f06dc4ed5c026d49f50a8 /Library/Homebrew/options.rb
parentfcf2c89c8c363bd797d281d025cd3d29151b14c8 (diff)
downloadhomebrew-096152214a6cf6cf6a50270f93b747568beb748b.tar.bz2
Replace Options.coerce with an alternate constructor
Diffstat (limited to 'Library/Homebrew/options.rb')
-rw-r--r--Library/Homebrew/options.rb31
1 files changed, 13 insertions, 18 deletions
diff --git a/Library/Homebrew/options.rb b/Library/Homebrew/options.rb
index 86be67ea9..a612f27fe 100644
--- a/Library/Homebrew/options.rb
+++ b/Library/Homebrew/options.rb
@@ -53,6 +53,19 @@ class Options
attr_reader :options
protected :options
+ def self.create(array)
+ options = new
+ array.each do |e|
+ case e
+ when /^-[^-]+$/
+ e[1..-1].split(//).each { |o| options << Option.new(o) }
+ else
+ options << Option.new(e)
+ end
+ end
+ options
+ end
+
def initialize(*args)
@options = Set.new(*args)
end
@@ -113,22 +126,4 @@ class Options
def inspect
"#<#{self.class.name}: #{to_a.inspect}>"
end
-
- def self.coerce(arg)
- case arg
- when Array
- opts = new
- arg.each do |a|
- case a
- when /^-[^-]+$/
- a[1..-1].split(//).each { |o| opts << Option.new(o) }
- else
- opts << Option.new(a)
- end
- end
- opts
- else
- raise TypeError, "Cannot convert #{arg.inspect} to Options"
- end
- end
end