Sha256: 9ac024558e8ae8d999f72d60465dc8709b75fe519d051ad1399ee51381fee9b8
Contents?: true
Size: 789 Bytes
Versions: 2
Compression:
Stored size: 789 Bytes
Contents
module Trav3 class Options def initialize(**args) build(**args) end def opts if @opts.empty? "" else "?#{@opts.join('&')}" end end def build(**args) @opts ||= [] for (key, value) in args remove(key) @opts.push(pb[key, value]) end end def remove(key) @opts = @opts.keep_if {|a, _| (eval ki)[a] } end def +(other) raise ArgumentError, "Invalid type provided." unless other.is_a?(Options) @opts += other.instance_variable_get(:@opts) end def to_s opts end def pb lambda {|param, arg| "#{param}=#{arg}" } end private :pb def ki 'lambda {|item| !(/^#{key}=/ === "#{item}") }' end private :ki end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
trav3-0.0.4 | lib/trav3/options.rb |
trav3-0.0.3 | lib/trav3/options.rb |