Class: PlayStationNetwork::Profile

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, avatar, username, about, membership, level, progress, trophies) ⇒ Profile

Returns a new instance of Profile.



12
13
14
15
16
17
18
19
20
21
# File 'lib/playstationnetwork/profile.rb', line 12

def initialize(id, avatar, username, about, membership, level, progress, trophies)
  self.id         = id
  self.avatar     = avatar
  self.username   = username
  self.about      = about
  self.membership = membership
  self.level      = level
  self.progress   = progress
  self.trophies   = trophies
end

Instance Attribute Details

#aboutObject

Returns the value of attribute about.



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

def about
  @about
end

#avatarObject

Returns the value of attribute avatar.



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

def avatar
  @avatar
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#levelObject

Returns the value of attribute level.



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

def level
  @level
end

#membershipObject

Returns the value of attribute membership.



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

def membership
  @membership
end

#progressObject

Returns the value of attribute progress.



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

def progress
  @progress
end

#trophiesObject

Returns the value of attribute trophies.



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

def trophies
  @trophies
end

#usernameObject

Returns the value of attribute username.



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

def username
  @username
end

Class Method Details

.find(username) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/playstationnetwork/profile.rb', line 23

def self.find(username)
  response = PlayStationNetwork::API.get("/#{username}")

  if response.success?
    self.new(
      response['npId'],
      response['avatarUrl'],
      response['onlineId'],
      response['aboutMe'],
      response['plus'],
      response['trophySummary']['level'],
      response['trophySummary']['progress'],
      response['trophySummary']['earnedTrophies']
    )
  else
    raise response.response
  end
end