Class: PlayStationNetwork::G::Games
- Inherits:
-
Object
- Object
- PlayStationNetwork::G::Games
- Defined in:
- lib/playstationnetwork/g/games.rb
Instance Attribute Summary collapse
-
#games ⇒ Object
Returns the value of attribute games.
-
#success ⇒ Object
Returns the value of attribute success.
-
#total_games ⇒ Object
Returns the value of attribute total_games.
Class Method Summary collapse
-
.all(psn_platform = 'all') ⇒ Object
Available platform options.
- .popular ⇒ Object
Instance Method Summary collapse
-
#initialize(success, total_games, games) ⇒ Games
constructor
A new instance of Games.
Constructor Details
#initialize(success, total_games, games) ⇒ Games
Returns a new instance of Games.
11 12 13 14 15 |
# File 'lib/playstationnetwork/g/games.rb', line 11 def initialize(success, total_games, games) self.success = success self.total_games = total_games self.games = games end |
Instance Attribute Details
#games ⇒ Object
Returns the value of attribute games.
9 10 11 |
# File 'lib/playstationnetwork/g/games.rb', line 9 def games @games end |
#success ⇒ Object
Returns the value of attribute success.
9 10 11 |
# File 'lib/playstationnetwork/g/games.rb', line 9 def success @success end |
#total_games ⇒ Object
Returns the value of attribute total_games.
9 10 11 |
# File 'lib/playstationnetwork/g/games.rb', line 9 def total_games @total_games end |
Class Method Details
.all(psn_platform = 'all') ⇒ Object
Available platform options
> all returns all PlayStation Network games
> psp2 returns all PSP games
> ps3 returns all PS3 games
> ps4 returns all PS4 games
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/playstationnetwork/g/games.rb', line 24 def self.all(psn_platform = 'all') = PlayStationNetwork::API.config.merge({ platform: psn_platform }) response = PlayStationNetwork::API.post('/psnListGames', body: ) sanitized_response = response.gsub('<?xml version=\"1.0\"?>', '').gsub('<\/', '</').tr('"', '') parsed_response = Hash.from_xml(sanitized_response) if response.success? new( (parsed_response['psn_api']['success'].to_i == 1 ? true : false), parsed_response['psn_api']['game'].size, parsed_response['psn_api']['game'] ) else raise response.response end end |
.popular ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/playstationnetwork/g/games.rb', line 42 def self.popular response = PlayStationNetwork::API.post('/psnPopularThisWeek') sanitized_response = response.gsub('<?xml version=\"1.0\"?>', '').gsub('<\/', '</').tr('"', '') parsed_response = Hash.from_xml(sanitized_response) if response.success? new( (parsed_response['psn_api']['success'].to_i == 1 ? true : false), parsed_response['psn_api']['game'].size, parsed_response['psn_api']['game'] ) else raise response.response end end |