Module: Touringplans
- Defined in:
- lib/touringplans.rb,
lib/touringplans/version.rb
Overview
list and show attractions and eateries at Walt Disney World
Defined Under Namespace
Modules: Types
Classes: Client, Connection, CounterServiceLocation, DiningVenueFull, Error, Hotel, HotelFull, ParkAttraction, ParkAttractionFull, RoutesTable, TableServiceLocation
Constant Summary
collapse
- ROUTES =
{
magic_kingdom_dining: {
method: "get",
path: "/magic-kingdom/dining.json"
},
magic_kingdom_attractions: {
method: "get",
path: "/magic-kingdom/attractions.json"
},
animal_kingdom_dining: {
method: "get",
path: "/animal-kingdom/dining.json"
},
animal_kingdom_attractions: {
method: "get",
path: "/animal-kingdom/attractions.json"
},
epcot_dining: {
method: "get",
path: "/epcot/dining.json"
},
epcot_attractions: {
method: "get",
path: "/epcot/attractions.json"
},
hollywood_studios_dining: {
method: "get",
path: "/hollywood-studios/dining.json"
},
hollywood_studios_attractions: {
method: "get",
path: "/hollywood-studios/attractions.json"
},
walt_disney_world_hotels: {
method: "get",
path: "/walt-disney-world/hotels.json"
},
walt_disney_world_campground: {
method: "get",
path: "/walt-disney-world/hotels.json"
},
walt_disney_world_deluxe_hotels: {
method: "get",
path: "/walt-disney-world/hotels.json"
},
walt_disney_world_deluxe_villas: {
method: "get",
path: "/walt-disney-world/hotels.json"
},
walt_disney_world_moderate_hotels: {
method: "get",
path: "/walt-disney-world/hotels.json"
},
walt_disney_world_value_hotels: {
method: "get",
path: "/walt-disney-world/hotels.json"
},
walt_disney_world_disney_springs_resorts: {
method: "get",
path: "/walt-disney-world/hotels.json"
}
}.freeze
- PLACE_KEYS =
%i[magic_kingdom
animal_kingdom
epcot
hollywood_studios
walt_disney_world].freeze
- INTERESTS =
%i[counter_services
table_services
dining
attractions
hotels
campground
deluxe_hotels
deluxe_villas
moderate_hotels
value_hotels
disney_springs_resorts].freeze
- HOTEL_CATEGORIES =
%i[campground
deluxe_hotels
deluxe_villas
moderate_hotels
value_hotels
disney_springs_resorts].freeze
- VERSION =
"0.3.6"
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
._assemble_route(collection, interest_type, venue) ⇒ Object
728
729
730
731
732
733
734
735
736
737
738
|
# File 'lib/touringplans.rb', line 728
def self._assemble_route(collection, interest_type, venue)
collection = collection.to_s.downcase.gsub(" ", "_").gsub("-", "_")
interest_type = interest_type.to_s.downcase.gsub(" ", "_").gsub("-", "_")
venue = venue.to_s.downcase.gsub(" ", "_").gsub("-", "_")
route = [collection, interest_type, venue].join("_")
route = [collection, interest_type].join("_") if venue == "list"
route
end
|
._collect_listing_hashes_from_response(interest, response) ⇒ Object
740
741
742
743
744
745
746
747
748
749
750
751
752
|
# File 'lib/touringplans.rb', line 740
def self._collect_listing_hashes_from_response(interest, response)
hotel_categories = %i[campground deluxe_hotels deluxe_villas moderate_hotels value_hotels disney_springs_resorts]
listing_hashes = response if interest == "attractions"
listing_hashes = response if interest == "dining"
listing_hashes = response[0] if interest == "counter services"
listing_hashes = response[1] if interest == "table services"
listing_hashes = list_all_hotels(response) if interest == "hotels"
listing_hashes = list_all_hotels(response) if hotel_categories.include? _symbolize(interest)
listing_hashes
end
|
._determine_interest_type(interest) ⇒ Object
709
710
711
712
713
714
715
716
717
|
# File 'lib/touringplans.rb', line 709
def self._determine_interest_type(interest)
interest_type = interest
interest_type = "dining" if interest == "counter services"
interest_type = "dining" if interest == "table services"
interest_type = "hotels" if %i[campground deluxe_hotels deluxe_villas moderate_hotels value_hotels disney_springs_resorts].include? _symbolize(interest)
interest_type
end
|
705
706
707
|
# File 'lib/touringplans.rb', line 705
def self._format_location_name(location_name)
location_name.to_s.downcase.gsub(" ", "-")
end
|
._set_model_from_hash(interest, hash) ⇒ Object
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
|
# File 'lib/touringplans.rb', line 789
def self._set_model_from_hash(interest, hash)
hotel_categories = %i[campground deluxe_hotels deluxe_villas moderate_hotels value_hotels disney_springs_resorts hotels]
if hash["permalink"].to_s.length > 1
listing = CounterServiceLocation.new(hash) if interest == "counter services"
listing = TableServiceLocation.new(hash) if interest == "table services"
listing = ParkAttraction.new(hash) if interest == "attractions"
listing = DiningVenueFull.new(hash) if interest == "dining"
listing = Hotel.new(hash) if hotel_categories.include? _symbolize(interest)
else
listing = DiningVenueFull.new(hash) if interest == "dining"
listing = ParkAttractionFull.new(hash) if interest == "attractions"
listing = HotelFull.new(hash) if hotel_categories.include? _symbolize(interest)
end
listing
end
|
._symbolize(item) ⇒ Object
719
720
721
722
723
724
725
726
|
# File 'lib/touringplans.rb', line 719
def self._symbolize(item)
str = item.to_s.downcase.gsub("/", " ").gsub("-", " ").strip
str = str.gsub(" ", "_")
str.to_sym
end
|
.list(interest, location) ⇒ Object
list interest at location current interest are “counter service” “table service”, and “attractions” current locations are the four parks
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
|
# File 'lib/touringplans.rb', line 631
def self.list(interest, location)
return "The location is not on Disney property" unless PLACE_KEYS.include? _symbolize(location)
return "The interest is not valid" unless INTERESTS.include? _symbolize(interest)
client = _setup_client
listings = []
interest_type = _determine_interest_type(interest)
route = _assemble_route(location, interest_type, "list")
response = client.send(route).parsed_response
listing_hashes = _collect_listing_hashes_from_response(interest, response)
listing_hashes.each do |item|
item["venue_permalink"] = location.to_s.downcase.gsub(" ", "-").gsub("_", "-")
end
listing_hashes.each do |hash|
listing = _set_model_from_hash(interest, hash)
listings << listing
end
listings = list_hotels_of_a_category(listings, interest) if HOTEL_CATEGORIES.include? _symbolize(interest)
listings
end
|
.list_all(interest_type) ⇒ Object
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
|
# File 'lib/touringplans.rb', line 655
def self.list_all(interest_type)
return "The interest_type is not valid" unless %i[dining attractions hotels].include? _symbolize(interest_type)
parks = ["Magic Kingdom", "Animal Kingdom", "Epcot", "Hollywood Studios"]
places = []
if interest_type == "attractions"
parks.each do |park|
list = Touringplans.list("attractions", park)
places << list
end
end
if interest_type == "dining"
parks.each do |park|
list = Touringplans.list("counter services", park)
places << list
list = Touringplans.list("table services", park)
places << list
end
end
if interest_type == "hotels"
HOTEL_CATEGORIES.each do |category|
list = Touringplans.list(category.to_s, "walt_disney_world")
places << list
end
end
places.flatten
end
|
.list_all_hotels(response_from_touringplans_hotels_url) ⇒ Object
754
755
756
757
758
759
760
761
762
763
764
|
# File 'lib/touringplans.rb', line 754
def self.list_all_hotels(response_from_touringplans_hotels_url)
listing_hashes = []
response_from_touringplans_hotels_url.each do |child|
child.each do |grandchild|
listing_hashes << grandchild if grandchild.class.to_s == "Array"
end
end
listing_hashes.flatten
end
|
.list_hotels_of_a_category(hotels, interest) ⇒ Object
search for hotels of a category_code
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
|
# File 'lib/touringplans.rb', line 767
def self.list_hotels_of_a_category(hotels, interest)
hotel_categories = { campground: "campground", deluxe_hotels: "deluxe",
deluxe_villas: "deluxe_villa", moderate_hotels: "moderate",
value_hotels: "value", disney_springs_resorts: NilClass }
if interest == "disney springs resorts"
hotels.find_all { |hotel| hotel.category_code.instance_of?(NilClass) }
else
hotels.find_all { |hotel| hotel.category_code == hotel_categories[_symbolize(interest)] }
end
end
|
.routes ⇒ Object
78
79
80
|
# File 'lib/touringplans.rb', line 78
def self.routes
ROUTES
end
|
.show(place, interest_type, permalink) ⇒ Object
687
688
689
690
691
692
693
694
695
696
|
# File 'lib/touringplans.rb', line 687
def self.show(place, interest_type, permalink)
return "The location is not on Disney property" unless PLACE_KEYS.include? _symbolize(place)
return "The interest_type is not valid" unless INTERESTS.include? _symbolize(interest_type)
client = _setup_client
route = _assemble_route(place, interest_type, permalink)
response = client.send(route).parsed_response
_set_model_from_hash(interest_type, response)
end
|
Instance Method Details
#generate_route_table ⇒ Object
785
786
787
|
# File 'lib/touringplans.rb', line 785
def generate_route_table
end
|