Class: ProxyRb::HttpProxy
- Inherits:
-
Object
- Object
- ProxyRb::HttpProxy
- Defined in:
- lib/proxy_rb/http_proxy.rb
Overview
Represent proxy
Instance Attribute Summary collapse
-
#credentials ⇒ Object
readonly
Returns the value of attribute credentials.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#full_url ⇒ ProxyUrl
Return proxy as full url.
- #host ⇒ Object
-
#initialize(parser) ⇒ HttpProxy
constructor
A new instance of HttpProxy.
- #password ⇒ Object
- #port ⇒ Object
-
#to_ref ⇒ Symbol
Convert to symbol to reference the proxy.
- #user ⇒ Object
Constructor Details
#initialize(parser) ⇒ HttpProxy
Returns a new instance of HttpProxy.
13 14 15 16 |
# File 'lib/proxy_rb/http_proxy.rb', line 13 def initialize(parser) @url = parser.proxy_url @credentials = parser.credentials end |
Instance Attribute Details
#credentials ⇒ Object (readonly)
Returns the value of attribute credentials.
11 12 13 |
# File 'lib/proxy_rb/http_proxy.rb', line 11 def credentials @credentials end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
11 12 13 |
# File 'lib/proxy_rb/http_proxy.rb', line 11 def url @url end |
Instance Method Details
#empty? ⇒ Boolean
34 35 36 |
# File 'lib/proxy_rb/http_proxy.rb', line 34 def empty? host.nil? || host.empty? end |
#full_url ⇒ ProxyUrl
Return proxy as full url
50 51 52 |
# File 'lib/proxy_rb/http_proxy.rb', line 50 def full_url ProxyUrl.build url.to_hash.merge(credentials.to_hash) end |
#host ⇒ Object
18 19 20 |
# File 'lib/proxy_rb/http_proxy.rb', line 18 def host url.host end |
#password ⇒ Object
30 31 32 |
# File 'lib/proxy_rb/http_proxy.rb', line 30 def password credentials.password end |
#port ⇒ Object
22 23 24 |
# File 'lib/proxy_rb/http_proxy.rb', line 22 def port url.port end |
#to_ref ⇒ Symbol
Convert to symbol to reference the proxy
42 43 44 |
# File 'lib/proxy_rb/http_proxy.rb', line 42 def to_ref Shellwords.escape(*[host, port, user].compact.join('_')).to_sym end |
#user ⇒ Object
26 27 28 |
# File 'lib/proxy_rb/http_proxy.rb', line 26 def user credentials.user_name end |