class Cline
Constants
- CITY
Public Class Methods
ckeck_input_piked(pik_hotel,input)
click to toggle source
# File lib/hotels_in_iraq/cli.rb, line 43 def self.ckeck_input_piked(pik_hotel,input) pik_hotel.between?(0,Hotel.all.size) end
hotel_list(input)
click to toggle source
# File lib/hotels_in_iraq/cli.rb, line 30 def self.hotel_list(input) Scrap.start_nokogiri(CITY[input-1]) Hotel.find_by_city_name(CITY[input-1]).each_with_index do |hotel , index| puts "#{index+1}) " + "#{hotel}".blue end print "\n\nPik a hotel number:".green pik_hotel = gets.strip.to_i if Cline.ckeck_input_piked(pik_hotel,input) Hotel.hotel_info(pik_hotel - 1) else puts "Wrong input please try again.".red end end
Public Instance Methods
start()
click to toggle source
# File lib/hotels_in_iraq/cli.rb, line 3 def start puts "+-----------------------------------+".yellow puts "| Welcome To Iraqi Hotels !!! |".yellow puts "+-----------------------------------+".yellow puts"" puts "1) Baghdad".blue puts "2) Erbil".blue puts "3) Exit".blue print "Enter your city number, please:".green input = gets.strip.to_i if input == 3 exit else while input != 3 if input == 2 Cline.hotel_list(input) start elsif input == 1 Cline.hotel_list(input) start else start end end end end