Class: Campgrounds::Base

Inherits:
Object
  • Object
show all
Includes:
GeoKit::Geocoders
Defined in:
lib/campgrounds/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key) ⇒ Base

Returns a new instance of Base.



7
8
9
# File 'lib/campgrounds/base.rb', line 7

def initialize(api_key)
  @api_key = api_key
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



5
6
7
# File 'lib/campgrounds/base.rb', line 5

def api_key
  @api_key
end

Instance Method Details

#campground_detailsObject



15
16
17
# File 'lib/campgrounds/base.rb', line 15

def campground_details
  @campground_details ||= Campgrounds::CampgroundDetails.new(@api_key)
end

#campground_searchObject



11
12
13
# File 'lib/campgrounds/base.rb', line 11

def campground_search
  @campground_search ||= Campgrounds::CampgroundSearch.new(@api_key)
end

#campsite_searchObject



19
20
21
# File 'lib/campgrounds/base.rb', line 19

def campsite_search
  @campsite_search ||= Campgrounds::CampsiteSearch.new(@api_key)
end

#query(path, options = {}) ⇒ Object

private



26
27
28
29
30
31
32
# File 'lib/campgrounds/base.rb', line 26

def query(path, options={})
  base_uri  = 'http://api.amp.active.com/camping'
  options['api_key'] = @api_key
  url = base_uri + path
  xml = RestClient.get url, {:params => options}
  data = XmlSimple.xml_in(xml.to_s, { 'KeyAttr' => 'name' })
end