class Top25::Cli
Public Instance Methods
display_places()
click to toggle source
# File lib/top25/cli.rb, line 51 def display_places Top25::Place.all.each do |pl| puts "#{pl.num}. #{pl.name}-based in: #{pl.location}" puts "Website: #{pl.url}" puts "-------------------------------------".colorize(:green) end end
home()
click to toggle source
# File lib/top25/cli.rb, line 3 def home puts "Search for the best in the world, choose one of the follwing numbers" puts "1. Hotels\n2. Restaurants\n3. Beaches\n4. for exit" take_input end
make_places(name)
click to toggle source
# File lib/top25/cli.rb, line 45 def make_places(name) scraper = Top25::Scraper.new arrofplaces = scraper.scrap_index_page(name) Top25::Place.create_from_collection(arrofplaces) end
run(place)
click to toggle source
# File lib/top25/cli.rb, line 39 def run(place) make_places(place) #add_attributes display_places end
search(s)
click to toggle source
# File lib/top25/cli.rb, line 15 def search(s) if s == "1" puts "Top 25 Hotels" puts "=================".colorize(:blue) run("Hotels") home elsif s == "2" puts "Top 25 Restaurants" puts "=================".colorize(:blue) run("Restaurants") home elsif s == "3" puts "Top 25 Beaches" puts "=================".colorize(:blue) run("Beaches") home elsif !(s.to_i.between?(1, 4)) puts "sorry, you only can search hotels,restaurants and beaches" home elsif s == "4" puts "Good bye ^ _ ^" end end
take_input()
click to toggle source
# File lib/top25/cli.rb, line 9 def take_input input ="" input = gets.strip search(input) end