Class: Ubcbooker::Account

Inherits:
Object
  • Object
show all
Defined in:
lib/ubcbooker/account.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAccount



5
6
7
8
9
10
# File 'lib/ubcbooker/account.rb', line 5

def initialize
  @config_path = File.expand_path("../config.yml", __FILE__)
  @account_info = YAML.load_file(@config_path)
  @username = @account_info["username"]
  @password = @account_info["password"]
end

Instance Attribute Details

#passwordObject

Returns the value of attribute password.



3
4
5
# File 'lib/ubcbooker/account.rb', line 3

def password
  @password
end

#usernameObject

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


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