top_25_travel_destinations 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 76775d3dc18fe7a0dfd13d030db82ff852741e45
4
- data.tar.gz: 23f6095ce6c81b551da96a6062564e223ea05ac3
3
+ metadata.gz: b89e7d602e8d580696fbd4363d7f3352a11c1a11
4
+ data.tar.gz: 341ebbfaf00d1623613b92dc9372232518339b98
5
5
  SHA512:
6
- metadata.gz: 86003c6eb09af444a433d8f50027f5da9939b6f9fddfe0520af8348ec12ab1ba2579bbfdf86ff9d4b1d11c74ade9b31bef4630925dab05941c787a7440522238
7
- data.tar.gz: 63539166c02e0c7f1f4fab196ace64e4d303557e2c8fa9af599467c7a789215ac0554f2b6a8583394956e29448547581938894e038eb8bc2d599d4dfee75e384
6
+ metadata.gz: bd0f2570ed134dce13548a07045b82994293ad76b8fed5590c8931cdcd8921b28bfab5ab9a9213743a14365a381f3cc5f9feeedef7e3555d0c0b64f1fb2cdeec
7
+ data.tar.gz: b211e25eb02425bdca5f331d229e2d176d1194f4f43927a35cf7a3bf1502a7520a91dd45338bf4b854dc146027a7c2afcb78d957f058665740dc23f98d7de7f3
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require './lib/top_25_travel_destinations'
3
+ require "bundler/setup"
4
+ require "top_25_travel_destinations"
5
+
4
6
 
5
7
  Top25TravelDestinations::CLI.new.call #the class we are using to initiate our CLI
@@ -4,7 +4,30 @@ class Top25TravelDestinations::CLI
4
4
 
5
5
  def call
6
6
  puts "Discover the top 25 travel destinations according to TripAdvisor!"
7
- Destination.new.list_destinations
8
- Destination.new.choose_destination
7
+
8
+ while @input != "exit"
9
+ Destination.list_destinations
10
+ puts "Type the number next to the city that you would like more information on, or type 'exit'"
11
+ @input = gets.chomp
12
+ choose_destination
13
+ Destination.destination_information(@input)
14
+ end
15
+ goodbye
16
+ end
17
+
18
+
19
+ def goodbye
20
+ puts "See you later for more destinations!"
21
+ exit
22
+ end
23
+
24
+ def choose_destination
25
+ if @input == "exit"
26
+ goodbye
27
+ elsif !@input.to_i.between?(1,25)
28
+ puts "Incorrect input, try again"
29
+ @input = gets.chomp.to_i
30
+ end
9
31
  end
10
- end #ends our Class
32
+
33
+ end #ends Class
@@ -1,1070 +1,60 @@
1
- class Destination
2
-
3
- attr_accessor :rank, :city, :country, :city_description, :list_destinations
4
-
5
- def choose_destination
6
- puts "Type the city that you would like more information on, or type 'exit'"
7
- input = nil #need this so that our while loop can function
8
- while input != "exit"
9
- input = gets.strip.downcase
10
- if input == "marrakech"
11
- destination_1
12
- elsif input == "siem reap"
13
- destination_2
14
- elsif input == "istanbul"
15
- destination_3
16
- elsif input == "hanoi"
17
- destination_4
18
- elsif input == "prague"
19
- destination_5
20
- elsif input == "london"
21
- destination_6
22
- elsif input == "rome"
23
- destination_7
24
- elsif input == "buenos aires"
25
- destination_8
26
- elsif input == "paris"
27
- destination_9
28
- elsif input == "cape town central"
29
- destination_10
30
- elsif input == "new york city"
31
- destination_11
32
- elsif input == "zermatt"
33
- destination_12
34
- elsif input == "barcelona"
35
- destination_13
36
- elsif input == "goreme"
37
- destination_14
38
- elsif input == "ubud"
39
- destination_15
40
- elsif input == "cusco"
41
- destination_16
42
- elsif input == "st. petersburg" || input == "st petersburg"
43
- destination_17
44
- elsif input == "bangkok"
45
- destination_18
46
- elsif input == "kathmandu"
47
- destination_19
48
- elsif input == "athens"
49
- destination_20
50
- elsif input == "budapest"
51
- destination_21
52
- elsif input == "queenstown"
53
- destination_22
54
- elsif input == "hong kong"
55
- destination_23
56
- elsif input == "dubai"
57
- destination_24
58
- elsif input == "sydney"
59
- destination_25
60
- elsif input == "exit"
61
- goodbye
62
- else
63
- puts "Incorrect input, please try again"
64
- end
65
- end
66
- end
67
-
68
- def goodbye
69
- puts "See you later for more destinations!"
70
- exit
71
- end
72
-
73
- def get_page
74
- Nokogiri::HTML(open("http://www.tripadvisor.com/TravelersChoice-Destinations"))
75
- end
76
-
77
-
78
- def get_destinations
79
- self.get_page.css('.tcDest.clickable')
80
- end
81
-
82
- def get_destination_details
83
- self.get_page.css('.tcDest_details')
84
- end
85
-
86
- def list_destinations
87
- array = []
88
- get_destinations.each do |x|
89
- array << x.css('div.tcCity').text
90
- end
91
- puts array
92
- end
93
-
94
- def destination_1
95
- dest = []
96
- get_destinations.css('#1').each do |x|
97
- dest << x.css('div.tcRank').text
98
- dest << x.css('div.tcCity').text
99
- dest << x.css('div.tcCountry').text
100
-
101
- end
102
- get_destination_details.css('#tcDest1_details').each do |d|
103
- dest << d.css('div.description p').text.gsub("Learn More >", "")
104
-
105
- end
106
-
107
- input = nil
108
- until input == "menu"
109
- puts "What would you like to know about #{dest[1]}?"
110
- puts "rank, country, description, or menu"
111
- input = gets.chomp.downcase
112
- if input == "rank"
113
- puts "----------------------"
114
- puts "The rank of #{dest[1]} is: #{dest[0]}"
115
- puts "----------------------"
116
-
117
- elsif input == "country"
118
- puts "----------------------"
119
- puts "#{dest[1]} is located in #{dest[2]}"
120
- puts "----------------------"
121
- elsif input == "description"
122
- puts "----------------------"
123
- puts dest[3]
124
- puts "----------------------"
125
- elsif input == "menu"
126
- list_destinations
127
- choose_destination
128
- else
129
- puts "Incorrect input, please try again"
130
- end
131
- end
132
- end
133
-
134
- def destination_2
135
- dest = []
136
- get_destinations.css('#2').each do |x|
137
- dest << x.css('div.tcRank').text
138
- dest << x.css('div.tcCity').text
139
- dest << x.css('div.tcCountry').text
140
-
141
- end
142
- get_destination_details.css('#tcDest2_details').each do |d|
143
- dest << d.css('div.description p').text.gsub("Learn More >", "")
144
-
145
- end
146
- input = nil
147
- until input == "menu"
148
- puts "What would you like to know about #{dest[1]}?"
149
- puts "rank, country, description, or menu"
150
- input = gets.chomp.downcase
151
- if input == "rank"
152
- puts "----------------------"
153
- puts "The rank of #{dest[1]} is: #{dest[0]}"
154
- puts "----------------------"
155
-
156
- elsif input == "country"
157
- puts "----------------------"
158
- puts "#{dest[1]} is located in #{dest[2]}"
159
- puts "----------------------"
160
- elsif input == "description"
161
- puts "----------------------"
162
- puts dest[3]
163
- puts "----------------------"
164
- elsif input == "menu"
165
- list_destinations
166
- choose_destination
167
- else
168
- puts "Incorrect input, please try again"
169
-
170
- end
171
- end
172
- end
173
-
174
- def destination_3
175
- dest = []
176
- get_destinations.css('#3').each do |x|
177
- dest << x.css('div.tcRank').text
178
- dest << x.css('div.tcCity').text
179
- dest << x.css('div.tcCountry').text
180
-
181
- end
182
- get_destination_details.css('#tcDest3_details').each do |d|
183
- dest << d.css('div.description p').text.gsub("Learn More >", "")
184
-
185
- end
186
- input = nil
187
- until input == "menu"
188
- puts "What would you like to know about #{dest[1]}?"
189
- puts "rank, country, description, or menu"
190
- input = gets.chomp.downcase
191
- if input == "rank"
192
- puts "----------------------"
193
- puts "The rank of #{dest[1]} is: #{dest[0]}"
194
- puts "----------------------"
195
-
196
- elsif input == "country"
197
- puts "----------------------"
198
- puts "#{dest[1]} is located in #{dest[2]}"
199
- puts "----------------------"
200
- elsif input == "description"
201
- puts "----------------------"
202
- puts dest[3]
203
- puts "----------------------"
204
- elsif input == "menu"
205
- list_destinations
206
- choose_destination
207
- else
208
- puts "Incorrect input, please try again"
209
-
210
- end
211
- end
212
- end
213
-
214
- def destination_4
215
- dest = []
216
- get_destinations.css('#4').each do |x|
217
- dest << x.css('div.tcRank').text
218
- dest << x.css('div.tcCity').text
219
- dest << x.css('div.tcCountry').text
220
-
221
- end
222
- get_destination_details.css('#tcDest4_details').each do |d|
223
- dest << d.css('div.description p').text.gsub("Learn More >", "")
224
-
225
- end
226
- input = nil
227
- until input == "menu"
228
- puts "What would you like to know about #{dest[1]}?"
229
- puts "rank, country, description, or menu"
230
- input = gets.chomp.downcase
231
- if input == "rank"
232
- puts "----------------------"
233
- puts "The rank of #{dest[1]} is: #{dest[0]}"
234
- puts "----------------------"
235
-
236
- elsif input == "country"
237
- puts "----------------------"
238
- puts "#{dest[1]} is located in #{dest[2]}"
239
- puts "----------------------"
240
- elsif input == "description"
241
- puts "----------------------"
242
- puts dest[3]
243
- puts "----------------------"
244
- elsif input == "menu"
245
- list_destinations
246
- choose_destination
247
- else
248
- puts "Incorrect input, please try again"
249
-
250
- end
251
- end
252
- end
253
-
254
- def destination_5
255
- dest = []
256
- get_destinations.css('#5').each do |x|
257
- dest << x.css('div.tcRank').text
258
- dest << x.css('div.tcCity').text
259
- dest << x.css('div.tcCountry').text
260
-
261
- end
262
- get_destination_details.css('#tcDest5_details').each do |d|
263
- dest << d.css('div.description p').text.gsub("Learn More >", "")
264
-
265
- end
266
- input = nil
267
- until input == "menu"
268
- puts "What would you like to know about #{dest[1]}?"
269
- puts "rank, country, description, or menu"
270
- input = gets.chomp.downcase
271
- if input == "rank"
272
- puts "----------------------"
273
- puts "The rank of #{dest[1]} is: #{dest[0]}"
274
- puts "----------------------"
275
-
276
- elsif input == "country"
277
- puts "----------------------"
278
- puts "#{dest[1]} is located in #{dest[2]}"
279
- puts "----------------------"
280
- elsif input == "description"
281
- puts "----------------------"
282
- puts dest[3]
283
- puts "----------------------"
284
- elsif input == "menu"
285
- list_destinations
286
- choose_destination
287
- else
288
- puts "Incorrect input, please try again"
289
-
290
- end
291
- end
292
- end
293
-
294
- def destination_6
295
- dest = []
296
- get_destinations.css('#6').each do |x|
297
- dest << x.css('div.tcRank').text
298
- dest << x.css('div.tcCity').text
299
- dest << x.css('div.tcCountry').text
300
-
301
- end
302
- get_destination_details.css('#tcDest6_details').each do |d|
303
- dest << d.css('div.description p').text.gsub("Learn More >", "")
304
-
305
- end
306
- input = nil
307
- until input == "menu"
308
- puts "What would you like to know about #{dest[1]}?"
309
- puts "rank, country, description, or menu"
310
- input = gets.chomp.downcase
311
- if input == "rank"
312
- puts "----------------------"
313
- puts "The rank of #{dest[1]} is: #{dest[0]}"
314
- puts "----------------------"
315
-
316
- elsif input == "country"
317
- puts "----------------------"
318
- puts "#{dest[1]} is located in #{dest[2]}"
319
- puts "----------------------"
320
- elsif input == "description"
321
- puts "----------------------"
322
- puts dest[3]
323
- puts "----------------------"
324
- elsif input == "menu"
325
- list_destinations
326
- choose_destination
327
- else
328
- puts "Incorrect input, please try again"
329
-
330
- end
331
- end
332
- end
333
-
334
- def destination_7
335
- dest = []
336
- get_destinations.css('#7').each do |x|
337
- dest << x.css('div.tcRank').text
338
- dest << x.css('div.tcCity').text
339
- dest << x.css('div.tcCountry').text
340
-
341
- end
342
- get_destination_details.css('#tcDest7_details').each do |d|
343
- dest << d.css('div.description p').text.gsub("Learn More >", "")
344
-
345
- end
346
- input = nil
347
- until input == "menu"
348
- puts "What would you like to know about #{dest[1]}?"
349
- puts "rank, country, description, or menu"
350
- input = gets.chomp.downcase
351
- if input == "rank"
352
- puts "----------------------"
353
- puts "The rank of #{dest[1]} is: #{dest[0]}"
354
- puts "----------------------"
355
-
356
- elsif input == "country"
357
- puts "----------------------"
358
- puts "#{dest[1]} is located in #{dest[2]}"
359
- puts "----------------------"
360
- elsif input == "description"
361
- puts "----------------------"
362
- puts dest[3]
363
- puts "----------------------"
364
- elsif input == "menu"
365
- list_destinations
366
- choose_destination
367
- else
368
- puts "Incorrect input, please try again"
369
-
370
- end
371
- end
372
- end
373
-
374
- def destination_8
375
- dest = []
376
- get_destinations.css('#8').each do |x|
377
- dest << x.css('div.tcRank').text
378
- dest << x.css('div.tcCity').text
379
- dest << x.css('div.tcCountry').text
380
-
381
- end
382
- get_destination_details.css('#tcDest8_details').each do |d|
383
- dest << d.css('div.description p').text.gsub("Learn More >", "")
384
-
385
- end
386
- input = nil
387
- until input == "menu"
388
- puts "What would you like to know about #{dest[1]}?"
389
- puts "rank, country, description, or menu"
390
- input = gets.chomp.downcase
391
- if input == "rank"
392
- puts "----------------------"
393
- puts "The rank of #{dest[1]} is: #{dest[0]}"
394
- puts "----------------------"
395
-
396
- elsif input == "country"
397
- puts "----------------------"
398
- puts "#{dest[1]} is located in #{dest[2]}"
399
- puts "----------------------"
400
- elsif input == "description"
401
- puts "----------------------"
402
- puts dest[3]
403
- puts "----------------------"
404
- elsif input == "menu"
405
- list_destinations
406
- choose_destination
407
- else
408
- puts "Incorrect input, please try again"
409
-
410
- end
411
- end
412
- end
413
-
414
- def destination_9
415
- dest = []
416
- get_destinations.css('#9').each do |x|
417
- dest << x.css('div.tcRank').text
418
- dest << x.css('div.tcCity').text
419
- dest << x.css('div.tcCountry').text
420
-
421
- end
422
- get_destination_details.css('#tcDest9_details').each do |d|
423
- dest << d.css('div.description p').text.gsub("Learn More >", "")
424
-
425
- end
426
- input = nil
427
- until input == "menu"
428
- puts "What would you like to know about #{dest[1]}?"
429
- puts "rank, country, description, or menu"
430
- input = gets.chomp.downcase
431
- if input == "rank"
432
- puts "----------------------"
433
- puts "The rank of #{dest[1]} is: #{dest[0]}"
434
- puts "----------------------"
435
-
436
- elsif input == "country"
437
- puts "----------------------"
438
- puts "#{dest[1]} is located in #{dest[2]}"
439
- puts "----------------------"
440
- elsif input == "description"
441
- puts "----------------------"
442
- puts dest[3]
443
- puts "----------------------"
444
- elsif input == "menu"
445
- list_destinations
446
- choose_destination
447
- else
448
- puts "Incorrect input, please try again"
449
-
450
- end
451
- end
452
- end
453
-
454
- def destination_10
455
- dest = []
456
- get_destinations.css('#10').each do |x|
457
- dest << x.css('div.tcRank').text
458
- dest << x.css('div.tcCity').text
459
- dest << x.css('div.tcCountry').text
460
-
461
- end
462
- get_destination_details.css('#tcDest10_details').each do |d|
463
- dest << d.css('div.description p').text.gsub("Learn More >", "")
464
-
465
- end
466
- input = nil
467
- until input == "menu"
468
- puts "What would you like to know about #{dest[1]}?"
469
- puts "rank, country, description, or menu"
470
- input = gets.chomp.downcase
471
- if input == "rank"
472
- puts "----------------------"
473
- puts "The rank of #{dest[1]} is: #{dest[0]}"
474
- puts "----------------------"
475
-
476
- elsif input == "country"
477
- puts "----------------------"
478
- puts "#{dest[1]} is located in #{dest[2]}"
479
- puts "----------------------"
480
- elsif input == "description"
481
- puts "----------------------"
482
- puts dest[3]
483
- puts "----------------------"
484
- elsif input == "menu"
485
- list_destinations
486
- choose_destination
487
- else
488
- puts "Incorrect input, please try again"
489
-
490
- end
491
- end
492
- end
493
-
494
- def destination_11
495
- dest = []
496
- get_destinations.css('#11').each do |x|
497
- dest << x.css('div.tcRank').text
498
- dest << x.css('div.tcCity').text
499
- dest << x.css('div.tcCountry').text
500
-
501
- end
502
- get_destination_details.css('#tcDest11_details').each do |d|
503
- dest << d.css('div.description p').text.gsub("Learn More >", "")
504
-
505
- end
506
- input = nil
507
- until input == "menu"
508
- puts "What would you like to know about #{dest[1]}?"
509
- puts "rank, country, description, or menu"
510
- input = gets.chomp.downcase
511
- if input == "rank"
512
- puts "----------------------"
513
- puts "The rank of #{dest[1]} is: #{dest[0]}"
514
- puts "----------------------"
515
-
516
- elsif input == "country"
517
- puts "----------------------"
518
- puts "#{dest[1]} is located in #{dest[2]}"
519
- puts "----------------------"
520
- elsif input == "description"
521
- puts "----------------------"
522
- puts dest[3]
523
- puts "----------------------"
524
- elsif input == "menu"
525
- list_destinations
526
- choose_destination
527
- else
528
- puts "Incorrect input, please try again"
529
-
530
- end
531
- end
532
- end
533
-
534
- def destination_12
535
- dest = []
536
- get_destinations.css('#12').each do |x|
537
- dest << x.css('div.tcRank').text
538
- dest << x.css('div.tcCity').text
539
- dest << x.css('div.tcCountry').text
540
-
541
- end
542
- get_destination_details.css('#tcDest12_details').each do |d|
543
- dest << d.css('div.description p').text.gsub("Learn More >", "")
544
-
545
- end
546
- input = nil
547
- until input == "menu"
548
- puts "What would you like to know about #{dest[1]}?"
549
- puts "rank, country, description, or menu"
550
- input = gets.chomp.downcase
551
- if input == "rank"
552
- puts "----------------------"
553
- puts "The rank of #{dest[1]} is: #{dest[0]}"
554
- puts "----------------------"
555
-
556
- elsif input == "country"
557
- puts "----------------------"
558
- puts "#{dest[1]} is located in #{dest[2]}"
559
- puts "----------------------"
560
- elsif input == "description"
561
- puts "----------------------"
562
- puts dest[3]
563
- puts "----------------------"
564
- elsif input == "menu"
565
- list_destinations
566
- choose_destination
567
- else
568
- puts "Incorrect input, please try again"
569
-
570
- end
571
- end
572
- end
573
-
574
- def destination_13
575
- dest = []
576
- get_destinations.css('#13').each do |x|
577
- dest << x.css('div.tcRank').text
578
- dest << x.css('div.tcCity').text
579
- dest << x.css('div.tcCountry').text
580
-
581
- end
582
- get_destination_details.css('#tcDest13_details').each do |d|
583
- dest << d.css('div.description p').text.gsub("Learn More >", "")
584
-
585
- end
586
- input = nil
587
- until input == "menu"
588
- puts "What would you like to know about #{dest[1]}?"
589
- puts "rank, country, description, or menu"
590
- input = gets.chomp.downcase
591
- if input == "rank"
592
- puts "----------------------"
593
- puts "The rank of #{dest[1]} is: #{dest[0]}"
594
- puts "----------------------"
595
-
596
- elsif input == "country"
597
- puts "----------------------"
598
- puts "#{dest[1]} is located in #{dest[2]}"
599
- puts "----------------------"
600
- elsif input == "description"
601
- puts "----------------------"
602
- puts dest[3]
603
- puts "----------------------"
604
- elsif input == "menu"
605
- list_destinations
606
- choose_destination
607
- else
608
- puts "Incorrect input, please try again"
609
-
610
- end
611
- end
612
- end
613
-
614
- def destination_14
615
- dest = []
616
- get_destinations.css('#14').each do |x|
617
- dest << x.css('div.tcRank').text
618
- dest << x.css('div.tcCity').text
619
- dest << x.css('div.tcCountry').text
620
-
621
- end
622
- get_destination_details.css('#tcDest14_details').each do |d|
623
- dest << d.css('div.description p').text.gsub("Learn More >", "")
624
-
625
- end
626
- input = nil
627
- until input == "menu"
628
- puts "What would you like to know about #{dest[1]}?"
629
- puts "rank, country, description, or menu"
630
- input = gets.chomp.downcase
631
- if input == "rank"
632
- puts "----------------------"
633
- puts "The rank of #{dest[1]} is: #{dest[0]}"
634
- puts "----------------------"
635
-
636
- elsif input == "country"
637
- puts "----------------------"
638
- puts "#{dest[1]} is located in #{dest[2]}"
639
- puts "----------------------"
640
- elsif input == "description"
641
- puts "----------------------"
642
- puts dest[3]
643
- puts "----------------------"
644
- elsif input == "menu"
645
- list_destinations
646
- choose_destination
647
- else
648
- puts "Incorrect input, please try again"
649
-
650
- end
651
- end
652
- end
653
-
654
- def destination_15
655
- dest = []
656
- get_destinations.css('#15').each do |x|
657
- dest << x.css('div.tcRank').text
658
- dest << x.css('div.tcCity').text
659
- dest << x.css('div.tcCountry').text
660
-
661
- end
662
- get_destination_details.css('#tcDest15_details').each do |d|
663
- dest << d.css('div.description p').text.gsub("Learn More >", "")
664
-
665
- end
666
- input = nil
667
- until input == "menu"
668
- puts "What would you like to know about #{dest[1]}?"
669
- puts "rank, country, description, or menu"
670
- input = gets.chomp.downcase
671
- if input == "rank"
672
- puts "----------------------"
673
- puts "The rank of #{dest[1]} is: #{dest[0]}"
674
- puts "----------------------"
675
-
676
- elsif input == "country"
677
- puts "----------------------"
678
- puts "#{dest[1]} is located in #{dest[2]}"
679
- puts "----------------------"
680
- elsif input == "description"
681
- puts "----------------------"
682
- puts dest[3]
683
- puts "----------------------"
684
- elsif input == "menu"
685
- list_destinations
686
- choose_destination
687
- else
688
- puts "Incorrect input, please try again"
689
-
690
- end
691
- end
692
- end
693
-
694
- def destination_16
695
- dest = []
696
- get_destinations.css('#16').each do |x|
697
- dest << x.css('div.tcRank').text
698
- dest << x.css('div.tcCity').text
699
- dest << x.css('div.tcCountry').text
700
-
701
- end
702
- get_destination_details.css('#tcDest16_details').each do |d|
703
- dest << d.css('div.description p').text.gsub("Learn More >", "")
704
-
705
- end
706
- input = nil
707
- until input == "menu"
708
- puts "What would you like to know about #{dest[1]}?"
709
- puts "rank, country, description, or menu"
710
- input = gets.chomp.downcase
711
- if input == "rank"
712
- puts "----------------------"
713
- puts "The rank of #{dest[1]} is: #{dest[0]}"
714
- puts "----------------------"
715
-
716
- elsif input == "country"
717
- puts "----------------------"
718
- puts "#{dest[1]} is located in #{dest[2]}"
719
- puts "----------------------"
720
- elsif input == "description"
721
- puts "----------------------"
722
- puts dest[3]
723
- puts "----------------------"
724
- elsif input == "menu"
725
- list_destinations
726
- choose_destination
727
- else
728
- puts "Incorrect input, please try again"
729
-
730
- end
731
- end
732
- end
733
-
734
- def destination_17
735
- dest = []
736
- get_destinations.css('#17').each do |x|
737
- dest << x.css('div.tcRank').text
738
- dest << x.css('div.tcCity').text
739
- dest << x.css('div.tcCountry').text
740
-
741
- end
742
- get_destination_details.css('#tcDest17_details').each do |d|
743
- dest << d.css('div.description p').text.gsub("Learn More >", "")
744
-
745
- end
746
- input = nil
747
- until input == "menu"
748
- puts "What would you like to know about #{dest[1]}?"
749
- puts "rank, country, description, or menu"
750
- input = gets.chomp.downcase
751
- if input == "rank"
752
- puts "----------------------"
753
- puts "The rank of #{dest[1]} is: #{dest[0]}"
754
- puts "----------------------"
755
-
756
- elsif input == "country"
757
- puts "----------------------"
758
- puts "#{dest[1]} is located in #{dest[2]}"
759
- puts "----------------------"
760
- elsif input == "description"
761
- puts "----------------------"
762
- puts dest[3]
763
- puts "----------------------"
764
- elsif input == "menu"
765
- list_destinations
766
- choose_destination
767
- else
768
- puts "Incorrect input, please try again"
769
-
770
- end
771
- end
772
- end
773
-
774
- def destination_18
775
- dest = []
776
- get_destinations.css('#18').each do |x|
777
- dest << x.css('div.tcRank').text
778
- dest << x.css('div.tcCity').text
779
- dest << x.css('div.tcCountry').text
780
-
781
- end
782
- get_destination_details.css('#tcDest18_details').each do |d|
783
- dest << d.css('div.description p').text.gsub("Learn More >", "")
784
-
785
- end
786
- input = nil
787
- until input == "menu"
788
- puts "What would you like to know about #{dest[1]}?"
789
- puts "rank, country, description, or menu"
790
- input = gets.chomp.downcase
791
- if input == "rank"
792
- puts "----------------------"
793
- puts "The rank of #{dest[1]} is: #{dest[0]}"
794
- puts "----------------------"
1
+ # 1. Downloading data from tripadvisor
2
+ # 2. Creating instance of destinations
3
+ # 3. Finding particular destinations
4
+ require 'nokogiri'
5
+ require 'open-uri'
795
6
 
796
- elsif input == "country"
797
- puts "----------------------"
798
- puts "#{dest[1]} is located in #{dest[2]}"
799
- puts "----------------------"
800
- elsif input == "description"
801
- puts "----------------------"
802
- puts dest[3]
803
- puts "----------------------"
804
- elsif input == "menu"
805
- list_destinations
806
- choose_destination
807
- else
808
- puts "Incorrect input, please try again"
809
-
810
- end
811
- end
812
- end
813
-
814
- def destination_19
815
- dest = []
816
- get_destinations.css('#19').each do |x|
817
- dest << x.css('div.tcRank').text
818
- dest << x.css('div.tcCity').text
819
- dest << x.css('div.tcCountry').text
820
-
821
- end
822
- get_destination_details.css('#tcDest19_details').each do |d|
823
- dest << d.css('div.description p').text.gsub("Learn More >", "")
824
-
825
- end
826
- input = nil
827
- until input == "menu"
828
- puts "What would you like to know about #{dest[1]}?"
829
- puts "rank, country, description, or menu"
830
- input = gets.chomp.downcase
831
- if input == "rank"
832
- puts "----------------------"
833
- puts "The rank of #{dest[1]} is: #{dest[0]}"
834
- puts "----------------------"
835
7
 
836
- elsif input == "country"
837
- puts "----------------------"
838
- puts "#{dest[1]} is located in #{dest[2]}"
839
- puts "----------------------"
840
- elsif input == "description"
841
- puts "----------------------"
842
- puts dest[3]
843
- puts "----------------------"
844
- elsif input == "menu"
845
- list_destinations
846
- choose_destination
847
- else
848
- puts "Incorrect input, please try again"
849
-
850
- end
851
- end
852
- end
8
+ class Destination
853
9
 
854
- def destination_20
855
- dest = []
856
- get_destinations.css('#20').each do |x|
857
- dest << x.css('div.tcRank').text
858
- dest << x.css('div.tcCity').text
859
- dest << x.css('div.tcCountry').text
860
-
861
- end
862
- get_destination_details.css('#tcDest20_details').each do |d|
863
- dest << d.css('div.description p').text.gsub("Learn More >", "")
864
-
865
- end
866
- input = nil
867
- until input == "menu"
868
- puts "What would you like to know about #{dest[1]}?"
869
- puts "rank, country, description, or menu"
870
- input = gets.chomp.downcase
871
- if input == "rank"
872
- puts "----------------------"
873
- puts "The rank of #{dest[1]} is: #{dest[0]}"
874
- puts "----------------------"
10
+ attr_accessor :rank, :city, :country, :city_description, :list_destinations
875
11
 
876
- elsif input == "country"
877
- puts "----------------------"
878
- puts "#{dest[1]} is located in #{dest[2]}"
879
- puts "----------------------"
880
- elsif input == "description"
881
- puts "----------------------"
882
- puts dest[3]
883
- puts "----------------------"
884
- elsif input == "menu"
885
- list_destinations
886
- choose_destination
887
- else
888
- puts "Incorrect input, please try again"
889
-
890
- end
891
- end
12
+ def self.find_destination_by_name(name)
13
+ @@all.detect{|d| d.name == name}
892
14
  end
15
+
893
16
 
894
- def destination_21
895
- dest = []
896
- get_destinations.css('#21').each do |x|
897
- dest << x.css('div.tcRank').text
898
- dest << x.css('div.tcCity').text
899
- dest << x.css('div.tcCountry').text
900
-
901
- end
902
- get_destination_details.css('#tcDest21_details').each do |d|
903
- dest << d.css('div.description p').text.gsub("Learn More >", "")
904
-
905
- end
906
- input = nil
907
- until input == "menu"
908
- puts "What would you like to know about #{dest[1]}?"
909
- puts "rank, country, description, or menu"
910
- input = gets.chomp.downcase
911
- if input == "rank"
912
- puts "----------------------"
913
- puts "The rank of #{dest[1]} is: #{dest[0]}"
914
- puts "----------------------"
915
-
916
- elsif input == "country"
917
- puts "----------------------"
918
- puts "#{dest[1]} is located in #{dest[2]}"
919
- puts "----------------------"
920
- elsif input == "description"
921
- puts "----------------------"
922
- puts dest[3]
923
- puts "----------------------"
924
- elsif input == "menu"
925
- list_destinations
926
- choose_destination
927
- else
928
- puts "Incorrect input, please try again"
929
-
930
- end
931
- end
17
+ def self.get_page
18
+ # the first time I call this method, i set an instance
19
+ # the second time i want to check if that instance variable exists
20
+ # if yes, return it
21
+ # else
22
+ # create
23
+ @doc ||= Nokogiri::HTML(open("http://www.tripadvisor.com/TravelersChoice-Destinations"))
24
+ # Memoization - poor man caching
932
25
  end
933
26
 
934
- def destination_22
935
- dest = []
936
- get_destinations.css('#22').each do |x|
937
- dest << x.css('div.tcRank').text
938
- dest << x.css('div.tcCity').text
939
- dest << x.css('div.tcCountry').text
940
-
941
- end
942
- get_destination_details.css('#tcDest22_details').each do |d|
943
- dest << d.css('div.description p').text.gsub("Learn More >", "")
944
-
945
- end
946
- input = nil
947
- until input == "menu"
948
- puts "What would you like to know about #{dest[1]}?"
949
- puts "rank, country, description, or menu"
950
- input = gets.chomp.downcase
951
- if input == "rank"
952
- puts "----------------------"
953
- puts "The rank of #{dest[1]} is: #{dest[0]}"
954
- puts "----------------------"
955
27
 
956
- elsif input == "country"
957
- puts "----------------------"
958
- puts "#{dest[1]} is located in #{dest[2]}"
959
- puts "----------------------"
960
- elsif input == "description"
961
- puts "----------------------"
962
- puts dest[3]
963
- puts "----------------------"
964
- elsif input == "menu"
965
- list_destinations
966
- choose_destination
967
- else
968
- puts "Incorrect input, please try again"
969
-
970
- end
971
- end
28
+ def self.get_destinations
29
+ @get_dest ||= self.get_page.css('.tcDest.clickable')
972
30
  end
973
31
 
974
- def destination_23
975
- dest = []
976
- get_destinations.css('#23').each do |x|
977
- dest << x.css('div.tcRank').text
978
- dest << x.css('div.tcCity').text
979
- dest << x.css('div.tcCountry').text
980
-
981
- end
982
- get_destination_details.css('#tcDest23_details').each do |d|
983
- dest << d.css('div.description p').text.gsub("Learn More >", "")
984
-
985
- end
986
- input = nil
987
- until input == "menu"
988
- puts "What would you like to know about #{dest[1]}?"
989
- puts "rank, country, description, or menu"
990
- input = gets.chomp.downcase
991
- if input == "rank"
992
- puts "----------------------"
993
- puts "The rank of #{dest[1]} is: #{dest[0]}"
994
- puts "----------------------"
995
32
 
996
- elsif input == "country"
997
- puts "----------------------"
998
- puts "#{dest[1]} is located in #{dest[2]}"
999
- puts "----------------------"
1000
- elsif input == "description"
1001
- puts "----------------------"
1002
- puts dest[3]
1003
- puts "----------------------"
1004
- elsif input == "menu"
1005
- list_destinations
1006
- choose_destination
1007
- else
1008
- puts "Incorrect input, please try again"
1009
-
1010
- end
33
+ def self.list_destinations
34
+ #lists all the destinations
35
+ @counter = 1
36
+ get_destinations.each do |x|
37
+ @dest = x.css('div.tcCity').text
38
+ puts "#{@counter}. #{@dest}"
39
+ @counter += 1
1011
40
  end
1012
41
  end
1013
42
 
1014
- def destination_24
43
+ def self.destination_information(input)
44
+ @get_dest_det ||= self.get_page.css('.tcDest_details')
45
+
1015
46
  dest = []
1016
- get_destinations.css('#24').each do |x|
47
+ get_destinations.css("##{input}").each do |x|
1017
48
  dest << x.css('div.tcRank').text
1018
49
  dest << x.css('div.tcCity').text
1019
50
  dest << x.css('div.tcCountry').text
1020
-
1021
51
  end
1022
- get_destination_details.css('#tcDest24_details').each do |d|
52
+ @get_dest_det.css("#tcDest#{input}_details").each do |d|
1023
53
  dest << d.css('div.description p').text.gsub("Learn More >", "")
1024
-
1025
- end
1026
- input = nil
1027
- until input == "menu"
1028
- puts "What would you like to know about #{dest[1]}?"
1029
- puts "rank, country, description, or menu"
1030
- input = gets.chomp.downcase
1031
- if input == "rank"
1032
- puts "----------------------"
1033
- puts "The rank of #{dest[1]} is: #{dest[0]}"
1034
- puts "----------------------"
1035
-
1036
- elsif input == "country"
1037
- puts "----------------------"
1038
- puts "#{dest[1]} is located in #{dest[2]}"
1039
- puts "----------------------"
1040
- elsif input == "description"
1041
- puts "----------------------"
1042
- puts dest[3]
1043
- puts "----------------------"
1044
- elsif input == "menu"
1045
- list_destinations
1046
- choose_destination
1047
- else
1048
- puts "Incorrect input, please try again"
1049
-
1050
- end
1051
54
  end
1052
- end
1053
55
 
1054
- def destination_25
1055
- dest = []
1056
- get_destinations.css('#25').each do |x|
1057
- dest << x.css('div.tcRank').text
1058
- dest << x.css('div.tcCity').text
1059
- dest << x.css('div.tcCountry').text
1060
-
1061
- end
1062
- get_destination_details.css('#tcDest25_details').each do |d|
1063
- dest << d.css('div.description p').text.gsub("Learn More >", "")
1064
-
1065
- end
1066
- input = nil
1067
- until input == "menu"
56
+ input = nil
57
+ until input == "menu"
1068
58
  puts "What would you like to know about #{dest[1]}?"
1069
59
  puts "rank, country, description, or menu"
1070
60
  input = gets.chomp.downcase
@@ -1083,12 +73,11 @@ class Destination
1083
73
  puts "----------------------"
1084
74
  elsif input == "menu"
1085
75
  list_destinations
1086
- choose_destination
1087
76
  else
1088
- puts "Incorrect input, please try again"
1089
-
77
+ puts "Incorrect input, please try again"
1090
78
  end
1091
79
  end
1092
80
  end
1093
81
 
82
+
1094
83
  end #ends class Destination
@@ -1,3 +1,3 @@
1
1
  module Top25TravelDestinations
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: top_25_travel_destinations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - aenser
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-28 00:00:00.000000000 Z
11
+ date: 2016-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler