lib/trav3/options.rb in trav3-0.0.5 vs lib/trav3/options.rb in trav3-0.1.0
- old
+ new
@@ -15,16 +15,18 @@
def build(**args)
@opts ||= []
for (key, value) in args
remove(key)
- @opts.push(pb[key, value])
+ @opts.push("#{key}=#{value}")
end
end
def remove(key)
- @opts = @opts.keep_if {|a, _| ki[key][a] }
+ @opts = @opts.keep_if {|item, _|
+ !(/^#{key}=/ === "#{item}")
+ }
end
def +(other)
raise ArgumentError, "Invalid type provided." unless other.is_a?(Options)
@opts += other.instance_variable_get(:@opts)
@@ -32,16 +34,10 @@
def to_s
opts
end
- def pb
- lambda {|param, arg| "#{param}=#{arg}" }
+ def to_h
+ @opts.map {|item| item.split("=") }.to_h
end
- private :pb
-
- def ki
- lambda {|key| lambda {|item| !(/^#{key}=/ === "#{item}") } }
- end
- private :ki
end
end