Class: TINCheck::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/tincheck/config.rb

Defined Under Namespace

Classes: Builder

Constant Summary collapse

OPTS =
i[password proxy_url url username xml_lib].freeze
SERVICE_URI =
URI.parse('https://www.tincheck.com/pvsws/pvsservice.asmx').freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**opts) ⇒ Config

Returns a new instance of Config.



40
41
42
43
44
45
46
47
# File 'lib/tincheck/config.rb', line 40

def initialize(**opts)
  @opts = opts.each_with_object({}) do |(k, v), h|
    OPTS.include?(k = k.to_sym) && h[k] = v.to_s
  end
  defaults!
  load_xml_lib
  proxy_uri!
end

Instance Attribute Details

#proxy_uriObject (readonly)

Returns the value of attribute proxy_uri.



38
39
40
# File 'lib/tincheck/config.rb', line 38

def proxy_uri
  @proxy_uri
end

Class Method Details

.build(&blk) ⇒ Object



29
30
31
# File 'lib/tincheck/config.rb', line 29

def build(&blk)
  Config::Builder.(&blk)
end

.with_obj(config) ⇒ Object



33
34
35
# File 'lib/tincheck/config.rb', line 33

def with_obj(config)
  config.is_a?(self) ? config : new(config)
end

Instance Method Details

#optsObject



49
50
51
# File 'lib/tincheck/config.rb', line 49

def opts
  @opts.dup
end

#proxy_argsObject



53
54
55
# File 'lib/tincheck/config.rb', line 53

def proxy_args
  @proxy_uri ? [@proxy_uri.host, @proxy_uri.port, @proxy_uri.user, @proxy_uri.password] : []
end

#with(**opts) ⇒ Object



57
58
59
# File 'lib/tincheck/config.rb', line 57

def with(**opts)
  self.class.new(@opts.merge(opts))
end