Collapse iteration to a map
This commit is contained in:
parent
750d7bb2c8
commit
977ae5f27d
@ -36,16 +36,7 @@ class Options
|
|||||||
include Enumerable
|
include Enumerable
|
||||||
|
|
||||||
def self.create(array)
|
def self.create(array)
|
||||||
options = new
|
new array.map { |e| Option.new(e[/^--(.+)$/, 1] || e) }
|
||||||
array.each do |e|
|
|
||||||
case e
|
|
||||||
when /^--(.+)$/
|
|
||||||
options << Option.new($1)
|
|
||||||
else
|
|
||||||
options << Option.new(e)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
options
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(*args)
|
def initialize(*args)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user