diff options
| author | Mike McQuaid | 2014-08-13 08:45:06 +0100 |
|---|---|---|
| committer | Mike McQuaid | 2014-08-13 08:45:06 +0100 |
| commit | e8d4522914784b0f245c7e2a5d1872025644deb9 (patch) | |
| tree | 8b11027206fa04239c2e69dc1d2df15c98acc0cf /Library/Homebrew/options.rb | |
| parent | 084d8138a9a93a521aeb7f9f76463d85da15fc61 (diff) | |
| download | homebrew-e8d4522914784b0f245c7e2a5d1872025644deb9.tar.bz2 | |
Revert "Replace Options.coerce with an alternate constructor"
This reverts commit 8d2ef974a3a87bf4207f71ccb8a7b4776e16a016.
Diffstat (limited to 'Library/Homebrew/options.rb')
| -rw-r--r-- | Library/Homebrew/options.rb | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/Library/Homebrew/options.rb b/Library/Homebrew/options.rb index a612f27fe..86be67ea9 100644 --- a/Library/Homebrew/options.rb +++ b/Library/Homebrew/options.rb @@ -53,19 +53,6 @@ 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 @@ -126,4 +113,22 @@ 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 |
