Class: ProxyRb::Credentials
- Inherits:
-
Object
- Object
- ProxyRb::Credentials
- Defined in:
- lib/proxy_rb/credentials.rb
Overview
Hold proxy credentials
Instance Attribute Summary collapse
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#user_name ⇒ Object
readonly
Returns the value of attribute user_name.
Instance Method Summary collapse
-
#empty? ⇒ TrueClass, FalseClass
Is credentials empty.
-
#initialize(user_name, password) ⇒ Credentials
constructor
A new instance of Credentials.
-
#to_hash ⇒ Hash
Convert to hash.
-
#to_s ⇒ String
Convert to string.
Constructor Details
#initialize(user_name, password) ⇒ Credentials
Returns a new instance of Credentials.
15 16 17 18 |
# File 'lib/proxy_rb/credentials.rb', line 15 def initialize(user_name, password) @user_name = user_name @password = password end |
Instance Attribute Details
#password ⇒ Object (readonly)
Returns the value of attribute password.
8 9 10 |
# File 'lib/proxy_rb/credentials.rb', line 8 def password @password end |
#user_name ⇒ Object (readonly)
Returns the value of attribute user_name.
8 9 10 |
# File 'lib/proxy_rb/credentials.rb', line 8 def user_name @user_name end |
Instance Method Details
#empty? ⇒ TrueClass, FalseClass
Is credentials empty
32 33 34 |
# File 'lib/proxy_rb/credentials.rb', line 32 def empty? !(user_name? && password?) end |
#to_hash ⇒ Hash
Convert to hash
40 41 42 43 44 45 |
# File 'lib/proxy_rb/credentials.rb', line 40 def to_hash { user_name: user_name, password: password } end |
#to_s ⇒ String
Convert to string
24 25 26 |
# File 'lib/proxy_rb/credentials.rb', line 24 def to_s Shellwords.escape(format('%s:%s', user_name, password)) end |