diff options
| author | Jack Nagel | 2014-08-12 23:55:28 -0500 | 
|---|---|---|
| committer | Jack Nagel | 2014-08-12 23:55:28 -0500 | 
| commit | 8d2ef974a3a87bf4207f71ccb8a7b4776e16a016 (patch) | |
| tree | f25128e58aab34cb381d7573a93cbeba78d017f2 /Library/Homebrew/options.rb | |
| parent | cee42c339e7632eab15111e2c4e6c121ace6f9e2 (diff) | |
| download | homebrew-8d2ef974a3a87bf4207f71ccb8a7b4776e16a016.tar.bz2 | |
Replace Options.coerce with an alternate constructor
Diffstat (limited to 'Library/Homebrew/options.rb')
| -rw-r--r-- | Library/Homebrew/options.rb | 31 | 
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 | 
