Class: Menu::Main

Inherits:
Base
  • Object
show all
Defined in:
lib/menu/main.rb

Overview

MenuMain handlers

Instance Method Summary collapse

Methods inherited from Base

#initialize, #run_default, #run_selected_command

Constructor Details

This class inherits a constructor from Menu::Base

Instance Method Details

#create_input_mapObject



24
25
26
27
28
29
30
# File 'lib/menu/main.rb', line 24

def create_input_map
  {
    setup: menu[:setup],
    login: menu[:login],
    logout: menu[:logout]
  }
end

#create_procs_mapObject



32
33
34
35
36
37
38
# File 'lib/menu/main.rb', line 32

def create_procs_map
  {
    setup: proc { run_setup },
    login: proc {  },
    logout: proc { run_logout }
  }
end

#run_loginObject

Login user



41
42
43
44
45
46
47
48
# File 'lib/menu/main.rb', line 41

def 
  if Communication::SessionManager.logged_in?
    Utilities.log("You are already logged in.", { type: :info })
  else
    Utilities.log("Please enter your login credentials.")
    SetupWizard.new.
  end
end

#run_logoutObject

Logout user



51
52
53
54
55
56
# File 'lib/menu/main.rb', line 51

def run_logout
  Communication::SessionManager.logout
  Utilities.log("Logout success.", { type: :success })
rescue LogworkException::UserNotLoggedIn => e
  Utilities.log(e, { type: :error })
end

#run_setupObject

Run setup wizard



59
60
61
# File 'lib/menu/main.rb', line 59

def run_setup
  SetupWizard.new.run
end