Class: VagrantPlugins::ProxyConf::UserinfoURI

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/vagrant-proxyconf/userinfo_uri.rb

Overview

Helper class that strips userinfo from the URI to separate attributes

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri) ⇒ UserinfoURI

Returns a new instance of UserinfoURI.

Parameters:

  • uri (String)

    the URI including optional userinfo



23
24
25
26
# File 'lib/vagrant-proxyconf/userinfo_uri.rb', line 23

def initialize(uri)
  @set = !!uri
  @uri = URI.parse(uri || '')
end

Instance Attribute Details

#hostString (readonly)

Returns the host.

Returns:

  • (String)

    the host



16
# File 'lib/vagrant-proxyconf/userinfo_uri.rb', line 16

def_delegators :@uri, :host, :port, :user

#passString (readonly)

Returns the password.

Returns:

  • (String)

    the password



20
# File 'lib/vagrant-proxyconf/userinfo_uri.rb', line 20

def_delegator :@uri, :password, :pass

#portString (readonly)

Returns the port.

Returns:

  • (String)

    the port



16
# File 'lib/vagrant-proxyconf/userinfo_uri.rb', line 16

def_delegators :@uri, :host, :port, :user

#userString (readonly)

Returns the username.

Returns:

  • (String)

    the username



16
# File 'lib/vagrant-proxyconf/userinfo_uri.rb', line 16

def_delegators :@uri, :host, :port, :user

Instance Method Details

#uriString Also known as: to_s

Returns the URI without userinfo.

Returns:

  • (String)

    the URI without userinfo



29
30
31
32
33
34
35
36
37
# File 'lib/vagrant-proxyconf/userinfo_uri.rb', line 29

def uri
  if !@set
    nil
  elsif @uri.to_s.empty?
    ""
  else
    "#{@uri.scheme}://#{host}:#{port}"
  end
end