Class: VegOut::CLI

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.create_listObject



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/veg_out/cli.rb', line 23

def self.create_list
  puts <<~eos

    ----------------------------------------------
    Here are places with options to eat near you!!
    ----------------------------------------------

  eos

  VegOut::Scraper::restaurants.each_with_index.map {|n, index| puts "#{index+1}. #{n} -- #{VegOut::Scraper::distance[index]} away" }

  self.show_details
end

.more_detailsObject



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

def self.more_details
  VegOut::Scraper.create_restaurant

  VegOut::Scraper::name.size.times {print "~"}
  puts ""
  puts VegOut::Scraper::name
  VegOut::Scraper::name.size.times {print "~"}
  puts ""
  puts VegOut::Scraper::description
  puts ""
  puts "Contact Info:"
  puts VegOut::Scraper::phone
  puts ""
  puts "Location:"
  puts VegOut::Scraper::address
  puts ""
  self.more_info
end

.more_infoObject



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

def self.more_info
puts <<~eos
  If you would like to see the list of restaurants again type 'list'
  To search a new area type 'back' or type 'quit' to exit
eos

input = gets.strip
  case input
    when "back"
      VegOut::CLI.new.start
    when "quit"
      exit
    when "list"
      self.create_list
    else
      puts ""
      puts "Not a valid choice!"
      self.more_info
    end
end

.retryObject



83
84
85
86
87
# File 'lib/veg_out/cli.rb', line 83

def self.retry
  puts ""
  puts "No nearby restaurants! Sorry!"
  VegOut::CLI.new.start
end

.show_detailsObject



58
59
60
61
62
# File 'lib/veg_out/cli.rb', line 58

def self.show_details
  puts ""
  puts "Which restaurant are you interested in learning more about:"
  VegOut::Scraper.find_details_page
end

Instance Method Details

#callObject



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/veg_out/cli.rb', line 3

def call
  puts <<~eos

                      ------------------
                      Welcome to Veg Out
                      ------------------

   The best place to find vegan and vegetarian restaurants near you!!

   eos
   start
end

#startObject



16
17
18
19
20
21
# File 'lib/veg_out/cli.rb', line 16

def start
  puts ""
  puts "Please enter the name of your city, or a 5 digit zip code:"

  VegOut::Scraper.get_page
end