Class: Brocktail::Credentials

Inherits:
Object
  • Object
show all
Defined in:
lib/brocktail/credentials.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username, password, ssl = true) ⇒ Credentials

Returns a new instance of Credentials.



6
7
8
# File 'lib/brocktail/credentials.rb', line 6

def initialize(username, password, ssl = true)
  @username, @password, @ssl = username, password, ssl
end

Instance Attribute Details

#passwordObject

Returns the value of attribute password.



4
5
6
# File 'lib/brocktail/credentials.rb', line 4

def password
  @password
end

#sslObject

Returns the value of attribute ssl.



4
5
6
# File 'lib/brocktail/credentials.rb', line 4

def ssl
  @ssl
end

#usernameObject

Returns the value of attribute username.



4
5
6
# File 'lib/brocktail/credentials.rb', line 4

def username
  @username
end

Instance Method Details

#basic_authObject



14
15
16
# File 'lib/brocktail/credentials.rb', line 14

def basic_auth
  Base64.encode64("#{username}:#{password}").delete("\r\n")
end

#hostObject



18
19
20
# File 'lib/brocktail/credentials.rb', line 18

def host
  "#{ssl ? "https" : "http"}://blocktail.heroku.com/api/v1"
end

#valid?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/brocktail/credentials.rb', line 10

def valid?
  !username.nil? && !password.nil?
end