Module: GamesRadarApi::Client::Games
- Included in:
- GamesRadarApi::Client
- Defined in:
- lib/games_radar_api/client/games.rb
Instance Method Summary collapse
- #game(id) ⇒ Object
- #game_search(query, platform, options = {:region=>'us'}) ⇒ Object
- #games(options = {:platform=>'all',:genre=>'all',:page_num=>1,:page_size=>10,:sort=>'newest'}) ⇒ Object
Instance Method Details
#game(id) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/games_radar_api/client/games.rb', line 15 def game(id) response = get("/game/#{id}") self.total_rows = response.total_rows.to_i game = if response.game.nil? or response.game.id.nil? nil else response.game end if !game.nil? if game.name.nil? game.name = nil elsif game.name.include?("us") game.name = game.name.us end if game.release_date.nil? game[:release_date] = nil end if game.platform.nil? game[:platform] = nil elsif game.platform.include?("name") game[:platform] = game.platform.name end if game.genre.nil? game[:genre] = nil elsif game.genre.include?("name") game[:genre] = game.genre.name end if game.publishers.nil? game[:publishers] = nil elsif game.publishers.include?("us") game[:publishers] = game.publishers.us end if game.description.nil? or game.description.empty? game[:description] = nil else game[:description] = game.description end if game.censorship.nil? game[:esrb] = nil else game[:esrb] = game.censorship.esrb. end if game.expected_release_date.nil? game.expected_release_date = nil elsif game.expected_release_date.include?("us") game.expected_release_date = game.expected_release_date.us end if game.developers.nil? game.developers = nil elsif game.developers.include?("company") game.developers = game.developers.company.name end if game.publishers.nil? game.publishers = nil elsif game.publishers.include?("company") game.publishers = game.publishers.company.name end end return game end |
#game_search(query, platform, options = {:region=>'us'}) ⇒ Object
88 89 90 91 92 |
# File 'lib/games_radar_api/client/games.rb', line 88 def game_search(query,platform,={:region=>'us'}) response = get("/search/gameName/#{platform}/#{query}",) self.total_rows = response.games.total_rows.to_i response.games.game end |
#games(options = {:platform=>'all',:genre=>'all',:page_num=>1,:page_size=>10,:sort=>'newest'}) ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/games_radar_api/client/games.rb', line 4 def games(={:platform=>'all',:genre=>'all',:page_num=>1,:page_size=>10,:sort=>'newest'}) response = get('/games',) self.total_rows = response.games.total_rows.to_i unless response.game.nil? or response.game.id.nil? if response.game.name.include?("us") response.game.name = response.game.name.us end end response.games.game end |