From 8d2ef974a3a87bf4207f71ccb8a7b4776e16a016 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Tue, 12 Aug 2014 23:55:28 -0500 Subject: Replace Options.coerce with an alternate constructor --- Library/Homebrew/options.rb | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) (limited to 'Library/Homebrew/options.rb') 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 -- cgit v1.2.3