Class: Randomeal::CLI

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#selectionObject

Returns the value of attribute selection.



3
4
5
# File 'lib/randomeal/cli.rb', line 3

def selection
  @selection
end

Instance Method Details

#callObject



5
6
7
8
9
10
# File 'lib/randomeal/cli.rb', line 5

def call
    puts "Thank you for using Randomeal!  Your options are loading."
    options
    secondary_menu_options
    secondary_menu
end


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

def menu

    input = gets.strip.downcase
    puts "-*-*-*-*-*-*-*-*-*"
    if input == "1" || input == "chicken"
        @selection = Randomeal::Food.new("chicken")
    elsif input == "2" || input == "burgers"
        @selection = Randomeal::Food.new("burger")
    elsif input == "3" || input ==  "pasta"
        @selection = Randomeal::Food.new("pasta")            
    elsif input == "4" || input == "salad"
        @selection = Randomeal::Food.new("salad")            
    elsif input == "5" || input == "dessert"
        @selection = Randomeal::Food.new("dessert")            
    else puts "That selection is not valid, please select from the list or 'exit'"
        options
    end

end

#optionsObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/randomeal/cli.rb', line 12

def options
    puts <<-MENU

    "-*-*-*-*-*-*-*-*-*"

    What would you like to eat?

    1. Chicken
    2. Burgers
    3. Pasta
    4. Salad
    5. Dessert
    MENU
    menu
end

#secondary_menuObject



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/randomeal/cli.rb', line 61

def secondary_menu

    input = nil

    while input != "exit"
    input = gets.strip.downcase
        if input == "1"
            puts @selection.ingredients
        elsif input == "2"
            puts @selection.directions
        elsif input == "3"
            self.options
        else
            puts "Please make a valid selection or 'exit"
        end
        puts ""
        puts "-*-*-*-*-*-*-*-*-*"
        secondary_menu_options
        puts "-*-*-*-*-*-*-*-*-*"
    end
end

#secondary_menu_optionsObject



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/randomeal/cli.rb', line 48

def secondary_menu_options
    puts <<-SECONDARY
    
    Your meal is #{@selection.title}
    1. For ingredients
    2. For directions
    3. If you don't want to eat #{@selection.title}
    
    Type 'exit' to  quit.
    SECONDARY
end