Class: Rockstar::Base
- Inherits:
-
Object
show all
- Defined in:
- lib/rockstar/base.rb
Direct Known Subclasses
Album, Artist, Auth, Chart, Event, Geo, Metro, Session, Tag, Track, User, Venue
Class Method Summary
collapse
Class Method Details
.fetch_and_parse(resource, params = {}, sign_request = false) ⇒ Object
12
13
14
|
# File 'lib/rockstar/base.rb', line 12
def fetch_and_parse(resource, params = {}, sign_request = false)
Hpricot::XML(connection.get(resource, sign_request, params))
end
|
.get_instance(api_method, instance_name, element, params, sign_request = false) ⇒ Object
16
17
18
19
20
|
# File 'lib/rockstar/base.rb', line 16
def get_instance(api_method, instance_name, element, params, sign_request = false)
rockstar_class = "rockstar/#{element.to_s}".camelize.constantize
doc = self.fetch_and_parse(api_method, params, sign_request)
(doc/element).inject([]) { |elements, el| elements << rockstar_class.new_from_xml(el, doc); elements }
end
|