Class: GiantBomb::Search
- Includes:
- HTTParty
- Defined in:
- lib/giant_bomb/search.rb
Instance Method Summary collapse
- #default_query_options ⇒ Object
- #find_game(keywords) ⇒ Object
- #get_game(game_id) ⇒ Object
- #get_game_info(game_id) ⇒ Object
-
#initialize(the_api_key) ⇒ Search
constructor
A new instance of Search.
Constructor Details
#initialize(the_api_key) ⇒ Search
Returns a new instance of Search.
8 9 10 |
# File 'lib/giant_bomb/search.rb', line 8 def initialize(the_api_key) @api_key = the_api_key end |
Instance Method Details
#default_query_options ⇒ Object
12 13 14 |
# File 'lib/giant_bomb/search.rb', line 12 def {"api_key" => @api_key, "format" => 'json'} end |
#find_game(keywords) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/giant_bomb/search.rb', line 18 def find_game(keywords) = {"query" => keywords, "resources" => "game"} .merge!() response = self.class.get("/search", :query => ) response["results"].collect{|r| Game.new(r, self)} end |
#get_game(game_id) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/giant_bomb/search.rb', line 33 def get_game(game_id) response = self.class.get("/game/#{game_id}/", :query => ) game = Game.new(response["results"], self) game.loaded = true game end |
#get_game_info(game_id) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/giant_bomb/search.rb', line 25 def get_game_info(game_id) field_list = %w{developers genres images publishers} = {"field_list" => field_list.join(',')} .merge!() response = self.class.get("/game/#{game_id}/", :query => ) Game.new(response["results"], self) end |