Method: Collins::Client#initialize

Defined in:
lib/collins/client.rb

#initialize(options = {}) ⇒ Client

Create a collins client instance

Parameters:

  • options (Hash) (defaults to: {})

    host, username and password are required

Options Hash (options):

  • :host (String)

    a scheme, hostname and port (e.g. hostname)

  • :logger (Logger)

    a logger to use, one is created if none is specified

  • :timeout (Fixnum) — default: 10

    timeout in seconds to wait for a response

  • :username (String)

    username for authentication

  • :password (String)

    password for authentication

  • :managed_process (String)
  • :strict (Boolean) — default: false

    see #strict



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/collins/client.rb', line 44

def initialize options = {}
  config = symbolize_hash options
  @locations = {}
  @headers = {}
  @host = fix_hostname(config.fetch(:host, ""))
  @logger = get_logger config.merge(:progname => 'Collins_Client')
  @timeout_i = config.fetch(:timeout, 10).to_i
  @username = config.fetch(:username, "")
  @password = config.fetch(:password, "")
  @strict = config.fetch(:strict, false)
  @managed_process = config.fetch(:managed_process, nil)
  require_non_empty(@host, "Collins::Client host must be specified")
  require_non_empty(@username, "Collins::Client username must be specified")
  require_non_empty(@password, "Collins::Client password must be specified")
end