Class: Credentials
- Inherits:
-
Object
- Object
- Credentials
- Defined in:
- lib/zooline/credentials.rb
Constant Summary collapse
- CRED_FILE =
"#{ENV['HOME']}/.zoocred"
Instance Attribute Summary collapse
-
#password ⇒ Object
Returns the value of attribute password.
-
#username ⇒ Object
Returns the value of attribute username.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(username = nil, password = nil) ⇒ Credentials
constructor
A new instance of Credentials.
- #open ⇒ Object
- #save! ⇒ Object
Constructor Details
#initialize(username = nil, password = nil) ⇒ Credentials
Returns a new instance of Credentials.
6 7 8 9 10 11 12 13 |
# File 'lib/zooline/credentials.rb', line 6 def initialize(username = nil, password = nil) if !username.nil? && !password.nil? @username = username @password = password else open end end |
Instance Attribute Details
#password ⇒ Object
Returns the value of attribute password.
2 3 4 |
# File 'lib/zooline/credentials.rb', line 2 def password @password end |
#username ⇒ Object
Returns the value of attribute username.
2 3 4 |
# File 'lib/zooline/credentials.rb', line 2 def username @username end |
Class Method Details
.check? ⇒ Boolean
34 35 36 |
# File 'lib/zooline/credentials.rb', line 34 def self.check? File.exist? CRED_FILE end |
.wipeout! ⇒ Object
30 31 32 |
# File 'lib/zooline/credentials.rb', line 30 def self.wipeout! FileUtils.rm CRED_FILE end |
Instance Method Details
#open ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/zooline/credentials.rb', line 22 def open File.open(CRED_FILE, "r") do |reado| content = reado.gets.split(",") @username = content.first @password = content.last end end |