Class: ChemistryKit::Config::BasicAuth
- Inherits:
-
Object
- Object
- ChemistryKit::Config::BasicAuth
- Defined in:
- lib/chemistrykit/config/basic_auth.rb
Instance Attribute Summary collapse
-
#base_url ⇒ Object
Returns the value of attribute base_url.
-
#http_path ⇒ Object
Returns the value of attribute http_path.
-
#https_path ⇒ Object
Returns the value of attribute https_path.
-
#password ⇒ Object
Returns the value of attribute password.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #http? ⇒ Boolean
- #http_url ⇒ Object
- #https? ⇒ Boolean
- #https_url ⇒ Object
-
#initialize(opts) ⇒ BasicAuth
constructor
A new instance of BasicAuth.
Constructor Details
#initialize(opts) ⇒ BasicAuth
Returns a new instance of BasicAuth.
9 10 11 12 13 14 15 16 17 |
# File 'lib/chemistrykit/config/basic_auth.rb', line 9 def initialize(opts) opts.each do |key, value| begin send("#{key}=", value) rescue NoMethodError raise ArgumentError.new "The config key: \"#{key}\" is unknown!" end end end |
Instance Attribute Details
#base_url ⇒ Object
Returns the value of attribute base_url.
7 8 9 |
# File 'lib/chemistrykit/config/basic_auth.rb', line 7 def base_url @base_url end |
#http_path ⇒ Object
Returns the value of attribute http_path.
7 8 9 |
# File 'lib/chemistrykit/config/basic_auth.rb', line 7 def http_path @http_path end |
#https_path ⇒ Object
Returns the value of attribute https_path.
7 8 9 |
# File 'lib/chemistrykit/config/basic_auth.rb', line 7 def https_path @https_path end |
#password ⇒ Object
Returns the value of attribute password.
7 8 9 |
# File 'lib/chemistrykit/config/basic_auth.rb', line 7 def password @password end |
#username ⇒ Object
Returns the value of attribute username.
7 8 9 |
# File 'lib/chemistrykit/config/basic_auth.rb', line 7 def username @username end |
Instance Method Details
#http? ⇒ Boolean
19 20 21 |
# File 'lib/chemistrykit/config/basic_auth.rb', line 19 def http? !!http_path end |
#http_url ⇒ Object
27 28 29 |
# File 'lib/chemistrykit/config/basic_auth.rb', line 27 def http_url base_url.gsub(%r{http://}, "http:\/\/#{username}:#{password}@") + (http_path || '') end |
#https? ⇒ Boolean
23 24 25 |
# File 'lib/chemistrykit/config/basic_auth.rb', line 23 def https? !!https_path end |
#https_url ⇒ Object
31 32 33 |
# File 'lib/chemistrykit/config/basic_auth.rb', line 31 def https_url base_url.gsub(%r{http://}, "https:\/\/#{username}:#{password}@") + (https_path || '') end |