Class: PlayStationNetwork::Game
- Inherits:
-
Object
- Object
- PlayStationNetwork::Game
- Defined in:
- lib/playstationnetwork/game.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #all(platform: 'all', popular: false) ⇒ Object
- #details ⇒ Object
-
#initialize(npcommid = "") ⇒ Game
constructor
A new instance of Game.
- #trophies ⇒ Object
Constructor Details
#initialize(npcommid = "") ⇒ Game
Returns a new instance of Game.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/playstationnetwork/game.rb', line 12 def initialize(npcommid = "") PlayStationNetwork::API.handle_response do raise INVALID_NPCOMMID_TYPE unless npcommid.is_a?(String) @options = PlayStationNetwork::API.request unless npcommid.blank? @options = @options.merge(npcommid: npcommid) end end end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
3 4 5 |
# File 'lib/playstationnetwork/game.rb', line 3 def @options end |
Instance Method Details
#all(platform: 'all', popular: false) ⇒ Object
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 |
# File 'lib/playstationnetwork/game.rb', line 36 def all(platform: 'all', popular: false) PlayStationNetwork::API.handle_response do raise INVALID_PLATFORM_TYPE unless platform.is_a?(String) raise INVALID_PLATFORM_PARAM unless GAMES_PARAMETERS_TYPES.include?(platform) raise INVALID_POPULAR_TYPE unless popular.is_a?(FalseClass) || popular.is_a?(TrueClass) if popular url = '/psnPopularThisWeek' else @options = .merge(platform: platform) url = '/psnListGames' end request = PlayStationNetwork::API.post(url, body: ) if request.success? begin parse_xml(request)['psn_api'] rescue raise "There was a problem parsing the XML response" end else raise request.response end end end |
#details ⇒ Object
24 25 26 27 28 |
# File 'lib/playstationnetwork/game.rb', line 24 def details PlayStationNetwork::API.handle_response do PlayStationNetwork::API.parse_response('/psnGetGame', ) end end |
#trophies ⇒ Object
30 31 32 33 34 |
# File 'lib/playstationnetwork/game.rb', line 30 def trophies PlayStationNetwork::API.handle_response do PlayStationNetwork::API.parse_response('/psnGetTrophies', ) end end |