class Agent
Attributes
key[RW]
Public Class Methods
new(key)
click to toggle source
pass in your API key generated from the GiantBomb sign up
# File lib/giant-bomber.rb, line 11 def initialize(key) @key = key @accept = "application/json" end
Public Instance Methods
game(id)
click to toggle source
get a game based on its unique GiantBomb id
# File lib/giant-bomber.rb, line 17 def game(id) self.class.get("/game/#{id}/?api_key=#{@key}&format=json&field_list=name,deck,description,genres,image")["results"] end
platform(id)
click to toggle source
Search for info about a platform, based on its name
# File lib/giant-bomber.rb, line 31 def platform(id) self.class.get("/platform/#{id}/?api_key=#{@key}&format=json&field_list=name,description,deck,release_date,image")["results"] end
platform_games(platform_id)
click to toggle source
get the 20 most popular games from the platform of choice
# File lib/giant-bomber.rb, line 57 def platform_games(platform_id) self.class.get("/games/?api_key=#{@key}&format=json&platforms=#{platform_id.to_i}&field_list=name,deck,image,id,original_release_date&sort=number_of_user_reviews:desc&limit=21")["results"] end
platform_id_hash()
click to toggle source
Create a relationship between platform name and its unique GiantBomb id
# File lib/giant-bomber.rb, line 36 def platform_id_hash list = platforms platform_hash = Hash.new list.each do |platform| platform_hash[platform["name"]] = platform["id"] end platform_hash end
platform_id_hash2()
click to toggle source
# File lib/giant-bomber.rb, line 46 def platform_id_hash2 list = second_platforms platform_hash = Hash.new list.each do |platform| platform_hash[platform["name"]] = platform["id"] end platform_hash end
platforms()
click to toggle source
get a list of platforms
# File lib/giant-bomber.rb, line 22 def platforms self.class.get("/platforms/?api_key=#{@key}&format=json&field_list=name,id")["results"] end
second_platforms()
click to toggle source
# File lib/giant-bomber.rb, line 26 def second_platforms self.class.get("/platforms/?api_key=#{@key}&format=json&field_list=name,id&offset=100")["results"] end