Class: PlayStationNetwork::Games

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(total_games, offset, limit, games) ⇒ Games

Returns a new instance of Games.



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

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

Instance Attribute Details

#gamesObject

Returns the value of attribute games.



3
4
5
# File 'lib/playstationnetwork/games.rb', line 3

def games
  @games
end

#limitObject

Returns the value of attribute limit.



3
4
5
# File 'lib/playstationnetwork/games.rb', line 3

def limit
  @limit
end

#offsetObject

Returns the value of attribute offset.



3
4
5
# File 'lib/playstationnetwork/games.rb', line 3

def offset
  @offset
end

#total_gamesObject

Returns the value of attribute total_games.



3
4
5
# File 'lib/playstationnetwork/games.rb', line 3

def total_games
  @total_games
end

Class Method Details

.find(username, offset = 0) ⇒ Object



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

def self.find(username, offset = 0)
  response = PlayStationNetwork::API.get("/#{username}/trophies/o/#{offset}")

  if response.success?
    new(
      response['totalResults'],
      response['offset'],
      response['limit'],
      response['trophyTitles']
    )
  else
    raise response.response
  end
end