Class: Qc::Credentials

Inherits:
Struct
  • Object
show all
Defined in:
lib/qc/credentials.rb

Constant Summary collapse

FILE_NAME =
'credentials.yml'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token

Returns:

  • (Object)

    the current value of access_token



2
3
4
# File 'lib/qc/credentials.rb', line 2

def access_token
  @access_token
end

#user_idObject

Returns the value of attribute user_id

Returns:

  • (Object)

    the current value of user_id



2
3
4
# File 'lib/qc/credentials.rb', line 2

def user_id
  @user_id
end

Class Method Details

.credentials_fileObject



21
22
23
# File 'lib/qc/credentials.rb', line 21

def self.credentials_file
  ::File.join(Qc::Util.home_dir, FILE_NAME)
end

.read_from_homeObject



5
6
7
8
# File 'lib/qc/credentials.rb', line 5

def self.read_from_home
  return nil unless ::File.exists?(credentials_file)
  YAML.load_file credentials_file
end

Instance Method Details

#destroyObject



17
18
19
# File 'lib/qc/credentials.rb', line 17

def destroy
  FileUtils.remove(self.class.credentials_file)
end

#save_to_homeObject



10
11
12
13
14
15
# File 'lib/qc/credentials.rb', line 10

def save_to_home
  FileUtils.mkdir_p(Qc::Util.home_dir)
  ::File.open(self.class.credentials_file, 'w') do |file|
    file.write self.to_yaml
  end
end