lib/trav3/options.rb in trav3-0.2.1 vs lib/trav3/options.rb in trav3-0.2.2
- old
+ new
@@ -24,17 +24,14 @@
end
def remove(key)
return_value = nil
- @opts = @opts.keep_if do |item, value|
- if entry_match?(key, item)
- return_value = value
- false
- else
- true
- end
+ @opts = @opts.delete_if do |item|
+ head, tail = split.call item
+
+ return_value = tail if head == key.to_s
end
return_value
end
@@ -53,15 +50,15 @@
def to_s
opts
end
def to_h
- @opts.map { |item| item.split('=') }.to_h
+ @opts.map(&split).to_h
end
private
- def entry_match?(entry, item)
- /^#{entry}=/.match? item.to_s
+ def split
+ ->(entry) { entry.split('=') }
end
end
end