Class: Brocktail::Credentials
- Inherits:
-
Object
- Object
- Brocktail::Credentials
- Defined in:
- lib/brocktail/credentials.rb
Instance Attribute Summary collapse
-
#password ⇒ Object
Returns the value of attribute password.
-
#ssl ⇒ Object
Returns the value of attribute ssl.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #basic_auth ⇒ Object
- #host ⇒ Object
-
#initialize(username, password, ssl = true) ⇒ Credentials
constructor
A new instance of Credentials.
- #valid? ⇒ Boolean
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
#password ⇒ Object
Returns the value of attribute password.
4 5 6 |
# File 'lib/brocktail/credentials.rb', line 4 def password @password end |
#ssl ⇒ Object
Returns the value of attribute ssl.
4 5 6 |
# File 'lib/brocktail/credentials.rb', line 4 def ssl @ssl end |
#username ⇒ Object
Returns the value of attribute username.
4 5 6 |
# File 'lib/brocktail/credentials.rb', line 4 def username @username end |
Instance Method Details
#basic_auth ⇒ Object
14 15 16 |
# File 'lib/brocktail/credentials.rb', line 14 def basic_auth Base64.encode64("#{username}:#{password}").delete("\r\n") end |
#host ⇒ Object
18 19 20 |
# File 'lib/brocktail/credentials.rb', line 18 def host "#{ssl ? "https" : "http"}://blocktail.heroku.com/api/v1" end |
#valid? ⇒ Boolean
10 11 12 |
# File 'lib/brocktail/credentials.rb', line 10 def valid? !username.nil? && !password.nil? end |