Method: CodeLabs::CLI#start

Defined in:
lib/code_labs/cli.rb

#startObject

The function that handles user input



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/code_labs/cli.rb', line 14

def start
    input = 'y'
    while input != 'exit' #untill the user types exit

        print "(tech/list/<number>/exit): "
        input = gets.strip.downcase
        pick_item(input.to_i - 1) if input.to_i > 0
        case input
        when "list"
            list_items
        when "tech"
            list_techs
        when "exit"
            puts ""
            puts "   Good                      ///"
            puts "      Bye!                  (o o)"
            puts "------------------------o00--( )--00o----"

        else
            puts("\n¯\_(ツ)_/¯ \nSorry, I do not know what that means") unless input == 'exit' || input.to_i > 0
            puts("(pst, try `1`)") if input.include?('number')
        end
    end
end