Sha256: d0169946faf1b3a6932554ad3cf106cd884b3587332bf097ebc7eddc3c7a5675
Contents?: true
Size: 746 Bytes
Versions: 1
Compression:
Stored size: 746 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("#{key}=#{value}") end self end def remove(key) @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) self end def to_s opts end def to_h @opts.map {|item| item.split("=") }.to_h end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
trav3-0.2.0 | lib/trav3/options.rb |