Class: Igdb::ApiResource
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Igdb::ApiResource
show all
- Defined in:
- lib/igdb/models/api_resource.rb
Direct Known Subclasses
Character, Collection, Company, Franchise, Game, GameEngine, GameMode, Genre, Keyword, Person, Platform, PlayerPerspective, Pulse, ReleaseDate, Review, Theme
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.path ⇒ Object
Returns the value of attribute path.
5
6
7
|
# File 'lib/igdb/models/api_resource.rb', line 5
def path
@path
end
|
.representer ⇒ Object
Returns the value of attribute representer.
6
7
8
|
# File 'lib/igdb/models/api_resource.rb', line 6
def representer
@representer
end
|
Class Method Details
.all(opts = {}) ⇒ Object
27
28
29
30
31
32
33
34
|
# File 'lib/igdb/models/api_resource.rb', line 27
def self.all(opts={})
params = Hash.new.tap do |hash|
hash['offset'] = opts[:offset] || 0
hash['limit'] = opts[:limit] || 50
hash['fields'] = '*'
end
build_collection(Igdb::Requester.get("#{self.path}", params), self.representer)
end
|
.count ⇒ Object
9
10
11
|
# File 'lib/igdb/models/api_resource.rb', line 9
def self.count
Igdb::Requester.get("#{self.path}/count")['count']
end
|
.find(id) ⇒ Object
13
14
15
16
|
# File 'lib/igdb/models/api_resource.rb', line 13
def self.find(id)
params = { fields: '*' }
build_single_resource(Igdb::Requester.get("#{self.path}/#{id}", params)[0], self.representer)
end
|
.search(opts = {}) ⇒ Object
18
19
20
21
22
23
24
25
|
# File 'lib/igdb/models/api_resource.rb', line 18
def self.search(opts={})
params = Hash.new.tap do |hash|
hash['search'] = opts[:query] if opts[:query]
hash['filters'] = opts[:filters] if opts[:filters]
hash['fields'] = '*'
end
build_collection(Igdb::Requester.get("#{self.path}", params), self.representer)
end
|