Class: HTTPX::Plugins::Proxy::Parameters
- Inherits:
-
Object
- Object
- HTTPX::Plugins::Proxy::Parameters
- Defined in:
- lib/httpx/plugins/proxy.rb
Instance Attribute Summary collapse
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #authenticated? ⇒ Boolean
-
#initialize(uri:, username: nil, password: nil) ⇒ Parameters
constructor
A new instance of Parameters.
- #token_authentication ⇒ Object
Constructor Details
#initialize(uri:, username: nil, password: nil) ⇒ Parameters
Returns a new instance of Parameters.
26 27 28 29 30 |
# File 'lib/httpx/plugins/proxy.rb', line 26 def initialize(uri:, username: nil, password: nil) @uri = uri.is_a?(URI::Generic) ? uri : URI(uri) @username = username || @uri.user @password = password || @uri.password end |
Instance Attribute Details
#password ⇒ Object (readonly)
Returns the value of attribute password.
24 25 26 |
# File 'lib/httpx/plugins/proxy.rb', line 24 def password @password end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
24 25 26 |
# File 'lib/httpx/plugins/proxy.rb', line 24 def uri @uri end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
24 25 26 |
# File 'lib/httpx/plugins/proxy.rb', line 24 def username @username end |
Instance Method Details
#==(other) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/httpx/plugins/proxy.rb', line 40 def ==(other) if other.is_a?(Parameters) @uri == other.uri && @username == other.username && @password == other.password else super end end |
#authenticated? ⇒ Boolean
32 33 34 |
# File 'lib/httpx/plugins/proxy.rb', line 32 def authenticated? @username && @password end |
#token_authentication ⇒ Object
36 37 38 |
# File 'lib/httpx/plugins/proxy.rb', line 36 def token_authentication Base64.strict_encode64("#{user}:#{password}") end |