Class: Starter

Inherits:
Object
  • Object
show all
Includes:
Commands
Defined in:
lib/starter.rb

Constant Summary

Constants included from Commands

Commands::GAMBLER

Instance Method Summary collapse

Methods included from Commands

#back, #clear, #continue, #fail, #fold, #help, #hint, #quit, #review, #skip, #welcome, #win

Constructor Details

#initializeStarter

Returns a new instance of Starter.



20
21
22
23
24
25
26
27
# File 'lib/starter.rb', line 20

def initialize
  RubyDrills::Config.pry_config
  clear
  welcome
  menu(drills)
  clear
  quit
end

Instance Method Details

#drillsObject



49
50
51
# File 'lib/starter.rb', line 49

def drills
  %w[welcome array string hash]
end


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/starter.rb', line 29

def menu(options)
  choice = nil
  valid_choices = valid_number_to_drill_associations(options)

  while (choice != 'q')
    if valid_choices.include?(choice)
      clear
      run_drill(options[choice.to_i])
    elsif (choice == 's')
      RubyDrills::Config::SESSIONS.stats
    end

    puts "\nWhat would you like to learn next?\n\n"
    options.each_with_index {|opt, i| puts "\t#{i}: #{opt.capitalize}"}
    puts "\n\tq: quit"

    choice = Readline.readline("\n>> ", true)
  end
end