Class: RestaurantViews

Inherits:
Object
  • Object
show all
Defined in:
lib/DinnerChoice/views/RestaurantView.rb

Instance Method Summary collapse

Instance Method Details

#delete_commandObject



35
36
37
38
39
40
41
42
# File 'lib/DinnerChoice/views/RestaurantView.rb', line 35

def delete_command
  puts 
  puts "Which restaurant do you want to delete from the list? Please input the ID number:"
  print "> "
  delete_id = gets.chomp.to_i
  delete_index = delete_id - 1
  return delete_index
end

#index(restaurant_database) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/DinnerChoice/views/RestaurantView.rb', line 4

def index(restaurant_database) 
  puts ('-' * 25).colorize(:light_blue)
  restaurant_database.each_with_index do |restaurant, index|
    puts "ID: #{index + 1}"
    puts "Name: #{restaurant.name}"
    puts "Address: #{restaurant.address}"
    puts "Rating: #{restaurant.rating}"
    puts "Average Price: $#{restaurant.average_price}"
    puts ('-' * 25).colorize(:light_blue)
    sleep 0.1
  end 
end


62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/DinnerChoice/views/RestaurantView.rb', line 62

def menu_list()
  puts 'main menu'.upcase.colorize(:light_yellow)
  puts '1. Create a new restaurant entry'
  puts '2. Display restaurants list'
  puts '3. Delete an existing entry'
  puts '4. Update info of an existing entry'
  puts '5. Make a choice! (random generator)'
  puts '6. Exit (or input "exit")'
  puts
  print 'Please select from the ' 
  print 'MAIN MENU '.colorize(:light_yellow)
  puts '(select numbers 1 to 6):'
  print '> '
  user_selection = gets.strip.downcase
end

#newObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/DinnerChoice/views/RestaurantView.rb', line 17

def new 
  puts 
  puts "What's the name of the restaurant you'd like to add?"
  print "> "
  name = gets.chomp
  puts "What's the address of the restaurant you'd like to add?"
  print "> "
  address = gets.chomp
  puts "How do you like this restaurant? please rate on a scale of 1-5, 1 being the lowest(poor), 5 being the highest(great)."
  print '> '
  rating = gets.chomp
  puts "How much do you usually spend in this restaurant?"
  print '> '
  average_price = gets.chomp
  puts
  [name, address, rating, average_price]
end

#update_commandObject



52
53
54
55
56
57
58
59
60
# File 'lib/DinnerChoice/views/RestaurantView.rb', line 52

def update_command
  puts "Which feature do you want to edit? Please select from name/address/rating/price:"
  print "> "
  select_item = gets.chomp.downcase
  puts "Please input new content:"
  print "> "
  update_content = gets.chomp
  [select_item, update_content]
end

#update_indexObject



44
45
46
47
48
49
50
# File 'lib/DinnerChoice/views/RestaurantView.rb', line 44

def update_index
  puts 
  puts "Which restaurant do you want to edit? Please input the ID number:"
  print "> "
  update_id = gets.chomp.to_i
  update_index = update_id - 1
end