Class: HackerToDo::Setup

Inherits:
Object
  • Object
show all
Defined in:
lib/hacker_todo_list/setup.rb

Constant Summary collapse

CREDENTIAL_FILE =
".hacker_todo"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSetup

Returns a new instance of Setup.



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/hacker_todo_list/setup.rb', line 6

def initialize
  credential_file_location = File.join(Dir.home, CREDENTIAL_FILE)
  if File.exists?(credential_file_location)
    @auth = YAML.load(File.read(credential_file_location))
  else
    @auth = {
      :username => HackerToDo.get_from_console("Username:"), 
      :password => HackerToDo.get_from_console("Password:", true)
    }
    File.write(credential_file_location, @auth.to_yaml)
  end
end

Instance Attribute Details

#authObject

Returns the value of attribute auth.



4
5
6
# File 'lib/hacker_todo_list/setup.rb', line 4

def auth
  @auth
end