Class: PlayStationNetwork::U::Games

Inherits:
Object
  • Object
show all
Defined in:
lib/playstationnetwork/u/games.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(total_games, games) ⇒ Games

Returns a new instance of Games.



7
8
9
10
# File 'lib/playstationnetwork/u/games.rb', line 7

def initialize(total_games, games)
  self.total_games = total_games
  self.games       = games
end

Instance Attribute Details

#gamesObject

Returns the value of attribute games.



5
6
7
# File 'lib/playstationnetwork/u/games.rb', line 5

def games
  @games
end

#total_gamesObject

Returns the value of attribute total_games.



5
6
7
# File 'lib/playstationnetwork/u/games.rb', line 5

def total_games
  @total_games
end

Class Method Details

.all(psn_user_id) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/playstationnetwork/u/games.rb', line 12

def self.all(psn_user_id)
  options  = PlayStationNetwork::API.config.merge({ user_id: psn_user_id })
  response = PlayStationNetwork::API.post('/psnGetUserGames', body: options)

  if response.success?
    parsed = JSON.parse(response)

    new(
      parsed['games'].size,
      parsed['games']
    )
  else
    raise response.response
  end
end