Class: TouristGuide::Cli
- Inherits:
-
Object
- Object
- TouristGuide::Cli
- Defined in:
- lib/tourist_guide/cli.rb
Instance Method Summary collapse
- #call ⇒ Object
- #create_directions(name) ⇒ Object
-
#directions(num) ⇒ Object
first_way.
- #display_directions ⇒ Object
- #list ⇒ Object
- #run(direction) ⇒ Object
- #user_insert ⇒ Object
Instance Method Details
#call ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/tourist_guide/cli.rb', line 3 def call puts " ✰✰✰✰✰".light_red puts " ✰✰✰✰✰ ✰✰✰✰✰ ✰✰✰✰✰ ✰✰✰✰✰".light_red puts " ✰✰✰✰✰ WELCOME TO THE TOURIST'S ERBIL GUIDE ✰✰✰✰✰".colorize(:color => :light_yellow).bold puts " version#{TouristGuide::VERSION}".colorize(:color => :yellow) puts " ✰✰✰✰✰ ✰✰✰✰✰ ✰✰✰✰✰".light_yellow puts " ✰✰✰✰✰ ✰✰✰✰✰".green puts " ✰✰✰✰✰".green list user_insert end |
#create_directions(name) ⇒ Object
134 135 136 137 138 |
# File 'lib/tourist_guide/cli.rb', line 134 def create_directions(name) scraping = TouristGuide::Scraping.new dir_attr = scraping.page_scraping(name) TouristGuide::Tour.create_from_collection(dir_attr) end |
#directions(num) ⇒ Object
first_way
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/tourist_guide/cli.rb', line 33 def directions(num) if num == "1" puts "ERBIL'S HOTELS LIST:" puts "" run("Hotels") list user_insert elsif num == "2" puts "ERBIL'S RESTAURANTS LIST:" puts "" run("Restaurants") list user_insert elsif num == "3" puts "ERBIL'S CAFETERIES LIST:" puts "" run("coffee%20shops") list user_insert elsif num == "4" puts "ERBIL'S PARKS LIST:" puts "" run("Parks") list user_insert elsif num == "5" puts "ERBIL'S MALLS LIST:" puts "" run("Malls") list user_insert elsif num == "6" call elsif num == "7" puts " THANK YOU! HAVE A NICE TIME!".magenta.bold else puts "" puts "" puts " NOT valid, please insert valid input ".colorize(:color => :white, :background => :red).bold puts "" list user_insert end end |
#display_directions ⇒ Object
140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/tourist_guide/cli.rb', line 140 def display_directions TouristGuide::Tour.all.each do |direction| #first_way # name= direction.name.ljust(38, ' ') # address= direction.address.ljust(21, ' ') # description= direction.description.ljust(0, ' ') # puts "Name: #{name} Address: #{address} Description: #{description}" #second_way puts "Name: #{direction.name.ljust(38, ' ').blue} Address: #{direction.address.ljust(21, ' ').blue} Description: #{direction.description.ljust(0, ' ').blue}" puts "_________________________________________________________________________________________________________________________".magenta end end |
#list ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/tourist_guide/cli.rb', line 15 def list puts "" puts "CHOOSE YOUR CATEGORY:".colorize(:color => :blue).bold # puts "----------------------------------------------------------------------------------------------------------------------------------------------------".colorize(:background => :light_blue) puts " ".colorize(:background => :blue) puts "" puts " 1. Hotels ♡ ♡ ♡ ♡ ♡ 2. Restaurants ♡ ♡ ♡ ♡ ♡ 3. Cafeterias ♡ ♡ ♡ ♡ ♡ 4. Parks ♡ ♡ ♡ ♡ ♡ 5. Malls".light_green puts "" puts " ♡ ♡ ♡ ♡ ♡ 6. Back to the main menu ♡ ♡ ♡ ♡ ♡ 7. Exit ♡ ♡ ♡ ♡ ♡ ".green end |
#run(direction) ⇒ Object
128 129 130 131 132 |
# File 'lib/tourist_guide/cli.rb', line 128 def run(direction) create_directions(direction) display_directions TouristGuide::Tour.clear end |
#user_insert ⇒ Object
26 27 28 29 30 |
# File 'lib/tourist_guide/cli.rb', line 26 def user_insert input = nil input = gets.strip directions(input) end |