Class: Harvest::Credentials
- Inherits:
-
Object
- Object
- Harvest::Credentials
- Defined in:
- lib/harvest/credentials.rb
Instance Attribute Summary collapse
-
#password ⇒ Object
Returns the value of attribute password.
-
#ssl ⇒ Object
Returns the value of attribute ssl.
-
#subdomain ⇒ Object
Returns the value of attribute subdomain.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #basic_auth ⇒ Object
- #host ⇒ Object
-
#initialize(subdomain, username, password, ssl = true) ⇒ Credentials
constructor
A new instance of Credentials.
- #valid? ⇒ Boolean
Constructor Details
#initialize(subdomain, username, password, ssl = true) ⇒ Credentials
Returns a new instance of Credentials.
5 6 7 |
# File 'lib/harvest/credentials.rb', line 5 def initialize(subdomain, username, password, ssl = true) @subdomain, @username, @password, @ssl = subdomain, username, password, ssl end |
Instance Attribute Details
#password ⇒ Object
Returns the value of attribute password.
3 4 5 |
# File 'lib/harvest/credentials.rb', line 3 def password @password end |
#ssl ⇒ Object
Returns the value of attribute ssl.
3 4 5 |
# File 'lib/harvest/credentials.rb', line 3 def ssl @ssl end |
#subdomain ⇒ Object
Returns the value of attribute subdomain.
3 4 5 |
# File 'lib/harvest/credentials.rb', line 3 def subdomain @subdomain end |
#username ⇒ Object
Returns the value of attribute username.
3 4 5 |
# File 'lib/harvest/credentials.rb', line 3 def username @username end |
Instance Method Details
#basic_auth ⇒ Object
13 14 15 |
# File 'lib/harvest/credentials.rb', line 13 def basic_auth Base64.encode64("#{username}:#{password}").delete("\r\n") end |
#host ⇒ Object
17 18 19 |
# File 'lib/harvest/credentials.rb', line 17 def host "#{ssl ? "https" : "http"}://#{subdomain}.harvestapp.com" end |
#valid? ⇒ Boolean
9 10 11 |
# File 'lib/harvest/credentials.rb', line 9 def valid? !subdomain.nil? && !username.nil? && !password.nil? end |