Module: AssLauncher::Cmd::Support::SrvStrParser Private

Included in:
Abstract::Option::Dbsrv, Abstract::Option::Esrv
Defined in:
lib/ass_launcher/cmd.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Mixin

Instance Method Summary collapse

Instance Method Details

#parse_srv_str(s) ⇒ Array

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parse string like user:password@host:port

Parameters:

Returns:

  • (Array)
    ‘host:port’, ‘user’, ‘password’


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/ass_launcher/cmd.rb', line 34

def parse_srv_str(s)
  split = s.split('@')
  fail ArgumentError if split.size > 2

  host = split.pop
  return [host, nil, nil] if split.size.zero?

  split = split[0].split(':')
  fail ArgumentError if split.size > 2

  user = split.shift
  pass = split.shift

  [host, user, pass]
end