Class: AuthBasic

Inherits:
Object
  • Object
show all
Includes:
AuthProvider
Defined in:
lib/sideko_hacker_news.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username: nil, password: nil) ⇒ AuthBasic

Returns a new instance of AuthBasic.



34
35
36
37
# File 'lib/sideko_hacker_news.rb', line 34

def initialize(username: nil, password: nil)
  @username = username
  @password = password
end

Instance Attribute Details

#passwordObject

Returns the value of attribute password.



32
33
34
# File 'lib/sideko_hacker_news.rb', line 32

def password
  @password
end

#usernameObject

Returns the value of attribute username.



32
33
34
# File 'lib/sideko_hacker_news.rb', line 32

def username
  @username
end

Instance Method Details

#add_auth(http_client, req_kwargs) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/sideko_hacker_news.rb', line 39

def add_auth(http_client, req_kwargs)
  if !@username.nil? && !@password.nil?
    http_client = http_client.basic_auth(user: @username, pass: @password)
  end

  return http_client, req_kwargs
end