Class: Ribose::CLI::RCFile

Inherits:
Object
  • Object
show all
Defined in:
lib/ribose/cli/rcfile.rb

Constant Summary collapse

FILE_NAME =
".riboserc".freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRCFile

Returns a new instance of RCFile.



10
11
12
13
# File 'lib/ribose/cli/rcfile.rb', line 10

def initialize
  @path = build_rcfile_path
  @data = load_configuration
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



7
8
9
# File 'lib/ribose/cli/rcfile.rb', line 7

def data
  @data
end

#pathObject (readonly)

Returns the value of attribute path.



7
8
9
# File 'lib/ribose/cli/rcfile.rb', line 7

def path
  @path
end

Class Method Details

.api_tokenObject



22
23
24
# File 'lib/ribose/cli/rcfile.rb', line 22

def self.api_token
  new.data[:api_token]
end

.set(token:, email:) ⇒ Object



30
31
32
# File 'lib/ribose/cli/rcfile.rb', line 30

def self.set(token:, email:)
  new.set(token: token, email: email)
end

.user_emailObject



26
27
28
# File 'lib/ribose/cli/rcfile.rb', line 26

def self.user_email
  new.data[:user_email]
end

Instance Method Details

#set(token:, email:) ⇒ Object



15
16
17
18
19
20
# File 'lib/ribose/cli/rcfile.rb', line 15

def set(token:, email:)
  data[:api_token] = token
  data[:user_email] = email

  write_api_details_to_file
end