Class: RMeetup::Fetcher::Base
- Inherits:
-
Object
- Object
- RMeetup::Fetcher::Base
- Defined in:
- lib/rmeetup/fetcher/base.rb
Overview
RMeetup::Fetcher::Base
Base fetcher class that other fetchers will inherit from.
Instance Method Summary collapse
-
#fetch(options = {}) ⇒ Object
Fetch and parse a response based on a set of options.
-
#initialize ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
20 21 22 |
# File 'lib/rmeetup/fetcher/base.rb', line 20 def initialize @type = nil end |
Instance Method Details
#fetch(options = {}) ⇒ Object
Fetch and parse a response based on a set of options. Override this method to ensure neccessary options are passed for the request.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rmeetup/fetcher/base.rb', line 29 def fetch( = {}) url = build_url() json = get_response(url) data = JSON.parse(json) # Check to see if the api returned an error raise ApiError.new(data['details'],url) if data.has_key?('problem') collection = RMeetup::Collection.build(data) # Format each result in the collection and return it collection.map!{|result| format_result(result)} end |