Class: WorldsBestRestaurants::CLI

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

Instance Method Summary collapse

Instance Method Details

#callObject



3
4
5
6
7
# File 'lib/worlds_best_restaurants/cli.rb', line 3

def call
  WorldsBestRestaurants::Scraper.new.make_restaurants
  puts "Welcome to the 50 Best Restaurants in the World"
  start
end


37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/worlds_best_restaurants/cli.rb', line 37

def print_restaurant(restaurant)
  puts ""
  puts "----------- #{restaurant.name} - #{restaurant.position} -----------"
  puts ""
  puts "Location:           #{restaurant.location}"
  puts "Head Chef:          #{restaurant.head_chef}"
  puts "Style of Food:      #{restaurant.food_style}"
  puts "Standout Dish:      #{restaurant.best_dish}"
  puts "Contact:            #{restaurant.contact}"
  puts "Website:            #{restaurant.website_url}"
  puts ""
  puts "---------------Description--------------"
  puts ""
  puts "#{restaurant.description}"
  puts ""
end


54
55
56
57
58
59
60
61
# File 'lib/worlds_best_restaurants/cli.rb', line 54

def print_restaurants(from_number)
  puts ""
  puts "---------- Restaurants #{from_number} - #{from_number+9} ----------"
  puts ""
  WorldsBestRestaurants::Restaurant.all[from_number-1, 10].each.with_index(from_number) do |restaurant, index|
    puts "#{index}. #{restaurant.name} - #{restaurant.location}"
  end  
end

#startObject



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

def start
  puts ""
  puts "What number restaurants would you like to see? 1-10, 11-20, 21-30, 31-40 or 41-50?"
  input = gets.strip.to_i

  print_restaurants(input)

  puts ""
  puts "What restaurant would you like more information on?"
  input = gets.strip

  restaurant = WorldsBestRestaurants::Restaurant.find(input.to_i)

  print_restaurant(restaurant)

  puts ""
  puts "Would you like to see another restaurant? Enter Y or N"

  input = gets.strip.downcase
  if input == "y"
    start
  else
    puts ""
    puts "Thankyou! Have a great day!"
    exit
  end    
end