Class: Campgrounds::CampgroundSearch
- Defined in:
- lib/campgrounds/campground_search.rb
Constant Summary collapse
- Path =
'/campgrounds'
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#all ⇒ Object
Retrieve all campgrounds.
-
#find(options = {}) ⇒ Object
A cleaned up version of the request method below.
-
#find_by_address(options = {}) ⇒ Object
Search for campgrounds with an address string and optional range in miles.
- #request(options = {}) ⇒ Object
Methods inherited from Base
#campground_details, #campground_search, #campsite_search, #initialize
Constructor Details
This class inherits a constructor from Campgrounds::Base
Instance Method Details
#all ⇒ Object
Retrieve all campgrounds.
7 8 9 |
# File 'lib/campgrounds/campground_search.rb', line 7 def all query(Path) end |
#find(options = {}) ⇒ Object
A cleaned up version of the request method below. Updated to use strings or boolean values instead of varius numbers.
Optional Parameters
landmarkLat: landmarkLong: These two parameters allow for campground searches around a fixed geo-point.
siteType: If unspecified, all site types are returned. "rv": RV Sites "cabin": Cabins or Lodgings "tent": Tent "trailer": Trailer "group": Group Site "day": Day Use "horse": Horse Site "boat": Boat Site
pstate: The two character abbreviation for US state, Canadian province or territory pname: Park Name arvDate: Arrival Date lengthOfStay: When combined with arvDate, this parameter determines how long the camper would like to reserve the campground.
amenity: Campground Feature. Only one amenity can be specified per query. Specifying amenity=4004, for example, returns campgrounds with fishing. Biking 4001 Boating 4002 Equipment Rental 4003 Fishing 4004 Golf 4005 Hiking 4006 Horseback Riding 4007 Hunting 4008 Recreational Activities 4009 Scenic Trails 4010 Sports 4011 Beach/Water Activities 4012 Winter Activities 4013
eqpLen: Equipment Length maxPeople: Number of campers
The following params seem to search correctly, though the results such as 'sitesWithAmps' may not return the expected results. It looks like some people put this info in the description field rather than the various Y/N fields. hookup: Electric Hookup "15+": 15 Amps or More "20+": 20 Amps or More "30+": 30 Amps or More "50+": 50 Amps or More
water: Water Hookup. Boolean. sewer: Sewer Hookup. Boolean. pull: Pull Through Driveway. Boolean. pets: Pets Allowed. Boolean. waterfront: Waterfront Sites. Boolean.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/campgrounds/campground_search.rb', line 65 def find(={}) case [:siteType] when "rv" [:siteType] = 2001 when "cabin" [:siteType] = 10001 when "tent" [:siteType] = 2003 when "trailer" [:siteType] = 2002 when "group" [:siteType] = 9002 when "day" [:siteType] = 9001 when "horse" [:siteType] = 3001 when "boat" [:siteType] = 2004 end case [:amenity] when "biking" [:amenity] = 4001 when "boating" [:amenity] = 4002 when "equipment rental" [:amenity] = 4003 when "fishing" [:amenity] = 4004 when "golf" [:amenity] = 4005 when "hiking" [:amenity] = 4006 when "horseback riding" [:amenity] = 4007 when "hunting" [:amenity] = 4008 when "recreational activities" [:amenity] = 4009 when "scenic trails" [:amenity] = 4010 when "sports" [:amenity] = 4011 when "beach/water activities" [:amenity] = 4012 when "winter activities" [:amenity] = 4013 end case [:hookup] when "15+" [:hookup] = 3002 when "20+" [:hookup] = 3003 when "30+" [:hookup] = 3004 when "50+" [:hookup] = 3005 end [:water] = 3006 if [:water] [:sewer] = 3007 if [:sewer] [:pull] = 3008 if [:pull] [:pets] = 3010 if [:pets] [:waterfront] = 3011 if [:waterfront] # Might return results array at some point, but returning the wrapper for now to keep results similar to default. return query(Path, ) end |
#find_by_address(options = {}) ⇒ Object
Search for campgrounds with an address string and optional range in miles. The address could be a street address, city and state, etc. Uses the find method so you can pass strings/booleans
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/campgrounds/campground_search.rb', line 137 def find_by_address(={}) address = [:address] [:range] ||= 1000 range = [:range] coords = MultiGeocoder.geocode(address) [:landmarkName] = true [:landmarkLat] = coords.lat [:landmarkLong] = coords.lng results = find() results['result'].each do |c| lat = c['latitude'] long = c['longitude'] c['distance'] = coords.distance_to([lat,long]) end results['result'].delete_if {|k, v| k['distance'] >= range } return results end |
#request(options = {}) ⇒ Object
216 217 218 |
# File 'lib/campgrounds/campground_search.rb', line 216 def request(={}) query(Path, ) end |