Class: Ubcbooker::Account
- Inherits:
-
Object
- Object
- Ubcbooker::Account
- Defined in:
- lib/ubcbooker/account.rb
Instance Attribute Summary collapse
-
#password ⇒ Object
Returns the value of attribute password.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #defined? ⇒ Boolean
-
#initialize ⇒ Account
constructor
A new instance of Account.
- #print_supported_departments ⇒ Object
- #write(username, password) ⇒ Object
Constructor Details
#initialize ⇒ Account
5 6 7 8 9 10 |
# File 'lib/ubcbooker/account.rb', line 5 def initialize @config_path = File.("../config.yml", __FILE__) @account_info = YAML.load_file(@config_path) @username = @account_info["username"] @password = @account_info["password"] end |
Instance Attribute Details
#password ⇒ Object
Returns the value of attribute password.
3 4 5 |
# File 'lib/ubcbooker/account.rb', line 3 def password @password end |
#username ⇒ Object
Returns the value of attribute username.
3 4 5 |
# File 'lib/ubcbooker/account.rb', line 3 def username @username end |
Instance Method Details
#defined? ⇒ Boolean
27 28 29 |
# File 'lib/ubcbooker/account.rb', line 27 def defined? return @account["username"] != "hoge" && @account["password"] != "hoge" end |
#print_supported_departments ⇒ Object
20 21 22 23 24 25 |
# File 'lib/ubcbooker/account.rb', line 20 def print_supported_departments puts "Supported department options in #{Ubcbooker::VERSION}:" BOOKING_URL.keys.each do |d| puts " - #{d}" end end |
#write(username, password) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/ubcbooker/account.rb', line 12 def write(username, password) @account["username"] = username @account["password"] = password new_yml = YAML.dump(@account) open(@config_path, "w") { |f| f.write(new_yml) } @account = YAML.load_file(@config_path) end |