Class: VagrantPlugins::ProxyConf::UserinfoURI
- Inherits:
-
Object
- Object
- VagrantPlugins::ProxyConf::UserinfoURI
- 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
-
#host ⇒ String
readonly
The host.
-
#port ⇒ String
readonly
The port.
Instance Method Summary collapse
-
#initialize(uri) ⇒ UserinfoURI
constructor
A new instance of UserinfoURI.
-
#pass ⇒ String
The password.
-
#uri ⇒ String
(also: #to_s)
The URI without userinfo.
-
#user ⇒ String
The username.
Constructor Details
#initialize(uri) ⇒ UserinfoURI
Returns a new instance of UserinfoURI.
17 18 19 20 |
# File 'lib/vagrant-proxyconf/userinfo_uri.rb', line 17 def initialize(uri) @set = !!uri @uri = URI.parse(uri || '') end |
Instance Attribute Details
#host ⇒ String (readonly)
Returns the host.
14 |
# File 'lib/vagrant-proxyconf/userinfo_uri.rb', line 14 def_delegators :@uri, :host, :port |
#port ⇒ String (readonly)
Returns the port.
14 |
# File 'lib/vagrant-proxyconf/userinfo_uri.rb', line 14 def_delegators :@uri, :host, :port |
Instance Method Details
#pass ⇒ String
Returns the password.
40 41 42 43 |
# File 'lib/vagrant-proxyconf/userinfo_uri.rb', line 40 def pass return URI.decode(@uri.password) if @uri.password @uri.password end |
#uri ⇒ String Also known as: to_s
Returns the URI without userinfo.
23 24 25 26 27 28 29 30 31 |
# File 'lib/vagrant-proxyconf/userinfo_uri.rb', line 23 def uri if !@set nil elsif @uri.to_s.empty? "" else "#{@uri.scheme}://#{host}:#{port}" end end |
#user ⇒ String
Returns the username.
34 35 36 37 |
# File 'lib/vagrant-proxyconf/userinfo_uri.rb', line 34 def user return URI.decode(@uri.user) if @uri.user @uri.user end |