Class: ProxyTester::HttpProxy
- Inherits:
-
Object
- Object
- ProxyTester::HttpProxy
- Defined in:
- lib/proxy_tester/http_proxy.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
-
#initialize(connection_string) ⇒ HttpProxy
constructor
A new instance of HttpProxy.
- #to_string(options = {}) ⇒ Object
- #use_user(user) ⇒ Object
Constructor Details
#initialize(connection_string) ⇒ HttpProxy
Returns a new instance of HttpProxy.
13 14 15 16 17 18 19 20 21 |
# File 'lib/proxy_tester/http_proxy.rb', line 13 def initialize(connection_string) match = connection_string_pattern.match(connection_string) || {} raise Exceptions::ProxyConnectionStringInvalid, JSON.dump(connection_string: connection_string) if match[:host].blank? raise Exceptions::ProxyConnectionStringInvalid, JSON.dump(connection_string: connection_string) if match[:port].blank? @host = match[:host] @port = match[:port] end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
11 12 13 |
# File 'lib/proxy_tester/http_proxy.rb', line 11 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
11 12 13 |
# File 'lib/proxy_tester/http_proxy.rb', line 11 def port @port end |
Instance Method Details
#to_string(options = {}) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/proxy_tester/http_proxy.rb', line 27 def to_string( = {}) result = [] result << 'http://' if user and [:cleartext] == true result << "#{user.name}:#{user.password}@" elsif user result << "#{user.name}:#{'*' * 4}@" if user end result << "#{host}:#{port}" result.join end |
#use_user(user) ⇒ Object
23 24 25 |
# File 'lib/proxy_tester/http_proxy.rb', line 23 def use_user(user) @user = user end |