aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/options.rb
diff options
context:
space:
mode:
authorJack Nagel2014-08-12 23:55:28 -0500
committerJack Nagel2014-08-12 23:55:28 -0500
commit25395c6de60849ea92c74bed8506d6e209ea7bf4 (patch)
tree8fc5879de012fead9ed6bcf7a17ed65697e3721b /Library/Homebrew/options.rb
parent0a2be32d802073ef46596792a46f7139bb862a8c (diff)
downloadbrew-25395c6de60849ea92c74bed8506d6e209ea7bf4.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