Class: PlayStationNetwork::U::User
- Inherits:
-
Object
- Object
- PlayStationNetwork::U::User
- Defined in:
- lib/playstationnetwork/u/user.rb
Instance Attribute Summary collapse
-
#about ⇒ Object
Returns the value of attribute about.
-
#avatar ⇒ Object
Returns the value of attribute avatar.
-
#bronze ⇒ Object
Returns the value of attribute bronze.
-
#completed_games ⇒ Object
Returns the value of attribute completed_games.
-
#completion_percentage ⇒ Object
Returns the value of attribute completion_percentage.
-
#country ⇒ Object
Returns the value of attribute country.
-
#gold ⇒ Object
Returns the value of attribute gold.
-
#hardcore_rank ⇒ Object
Returns the value of attribute hardcore_rank.
-
#level ⇒ Object
Returns the value of attribute level.
-
#membership ⇒ Object
Returns the value of attribute membership.
-
#platinum ⇒ Object
Returns the value of attribute platinum.
-
#points ⇒ Object
Returns the value of attribute points.
-
#points_base ⇒ Object
Returns the value of attribute points_base.
-
#points_next ⇒ Object
Returns the value of attribute points_next.
-
#profile ⇒ Object
Returns the value of attribute profile.
-
#progress ⇒ Object
Returns the value of attribute progress.
-
#projected_level ⇒ Object
Returns the value of attribute projected_level.
-
#projected_progress ⇒ Object
Returns the value of attribute projected_progress.
-
#region ⇒ Object
Returns the value of attribute region.
-
#region_rank ⇒ Object
Returns the value of attribute region_rank.
-
#silver ⇒ Object
Returns the value of attribute silver.
-
#stats ⇒ Object
Returns the value of attribute stats.
-
#total ⇒ Object
Returns the value of attribute total.
-
#total_games ⇒ Object
Returns the value of attribute total_games.
-
#total_possible ⇒ Object
Returns the value of attribute total_possible.
-
#trophies ⇒ Object
Returns the value of attribute trophies.
-
#username ⇒ Object
Returns the value of attribute username.
-
#world_rank ⇒ Object
Returns the value of attribute world_rank.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(membership, avatar, username, about, country, region, total, platinum, gold, silver, bronze, total_possible, points_base, points, points_next, level, projected_level, progress, projected_progress, total_games, completed_games, completion_percentage, world_rank, region_rank, hardcore_rank) ⇒ User
constructor
A new instance of User.
Constructor Details
#initialize(membership, avatar, username, about, country, region, total, platinum, gold, silver, bronze, total_possible, points_base, points, points_next, level, projected_level, progress, projected_progress, total_games, completed_games, completion_percentage, world_rank, region_rank, hardcore_rank) ⇒ User
Returns a new instance of User.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 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 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/playstationnetwork/u/user.rb', line 12 def initialize( membership, avatar, username, about, country, region, total, platinum, gold, silver, bronze, total_possible, points_base, points, points_next, level, projected_level, progress, projected_progress, total_games, completed_games, completion_percentage, world_rank, region_rank, hardcore_rank ) # Build the Profile Hash # psn_profile = Hash.new psn_profile[:membership] = membership.to_i psn_profile[:avatar] = avatar psn_profile[:username] = username psn_profile[:about] = about psn_profile[:location] = Hash.new psn_profile[:location][:country] = country psn_profile[:location][:region] = region # Build the Trophies hash # psn_profile_trophies = Hash.new psn_profile_trophies[:total] = total.to_i psn_profile_trophies[:platinum] = platinum.to_i psn_profile_trophies[:gold] = gold.to_i psn_profile_trophies[:silver] = silver.to_i psn_profile_trophies[:bronze] = bronze.to_i psn_profile_trophies[:total_possible] = total_possible.to_i # Build the Points hash # psn_profile_points = Hash.new psn_profile_points[:base] = points_base.to_i psn_profile_points[:actual] = points.to_i psn_profile_points[:next] = points_next.to_i # Build the Level hash # psn_profile_level = Hash.new psn_profile_level[:level] = level.to_i psn_profile_level[:projected_level] = projected_level.to_i psn_profile_level[:progress] = progress.to_f psn_profile_level[:projected_progress] = projected_progress.to_f # Build the Points hash # psn_profile_stats = Hash.new psn_profile_stats[:games] = total_games.to_i psn_profile_stats[:completed_games] = completed_games.to_i psn_profile_stats[:completion_percentage] = completion_percentage.to_f psn_profile_stats[:rank] = Hash.new psn_profile_stats[:rank][:world_rank] = world_rank.to_i psn_profile_stats[:rank][:region_rank] = region_rank.to_i psn_profile_stats[:rank][:hardcore_rank] = hardcore_rank.to_i self.profile = psn_profile self.trophies = psn_profile_trophies self.level = psn_profile_level self.points = psn_profile_points self.stats = psn_profile_stats end |
Instance Attribute Details
#about ⇒ Object
Returns the value of attribute about.
5 6 7 |
# File 'lib/playstationnetwork/u/user.rb', line 5 def about @about end |
#avatar ⇒ Object
Returns the value of attribute avatar.
5 6 7 |
# File 'lib/playstationnetwork/u/user.rb', line 5 def avatar @avatar end |
#bronze ⇒ Object
Returns the value of attribute bronze.
5 6 7 |
# File 'lib/playstationnetwork/u/user.rb', line 5 def bronze @bronze end |
#completed_games ⇒ Object
Returns the value of attribute completed_games.
5 6 7 |
# File 'lib/playstationnetwork/u/user.rb', line 5 def completed_games @completed_games end |
#completion_percentage ⇒ Object
Returns the value of attribute completion_percentage.
5 6 7 |
# File 'lib/playstationnetwork/u/user.rb', line 5 def completion_percentage @completion_percentage end |
#country ⇒ Object
Returns the value of attribute country.
5 6 7 |
# File 'lib/playstationnetwork/u/user.rb', line 5 def country @country end |
#gold ⇒ Object
Returns the value of attribute gold.
5 6 7 |
# File 'lib/playstationnetwork/u/user.rb', line 5 def gold @gold end |
#hardcore_rank ⇒ Object
Returns the value of attribute hardcore_rank.
5 6 7 |
# File 'lib/playstationnetwork/u/user.rb', line 5 def hardcore_rank @hardcore_rank end |
#level ⇒ Object
Returns the value of attribute level.
5 6 7 |
# File 'lib/playstationnetwork/u/user.rb', line 5 def level @level end |
#membership ⇒ Object
Returns the value of attribute membership.
5 6 7 |
# File 'lib/playstationnetwork/u/user.rb', line 5 def membership @membership end |
#platinum ⇒ Object
Returns the value of attribute platinum.
5 6 7 |
# File 'lib/playstationnetwork/u/user.rb', line 5 def platinum @platinum end |
#points ⇒ Object
Returns the value of attribute points.
5 6 7 |
# File 'lib/playstationnetwork/u/user.rb', line 5 def points @points end |
#points_base ⇒ Object
Returns the value of attribute points_base.
5 6 7 |
# File 'lib/playstationnetwork/u/user.rb', line 5 def points_base @points_base end |
#points_next ⇒ Object
Returns the value of attribute points_next.
5 6 7 |
# File 'lib/playstationnetwork/u/user.rb', line 5 def points_next @points_next end |
#profile ⇒ Object
Returns the value of attribute profile.
5 6 7 |
# File 'lib/playstationnetwork/u/user.rb', line 5 def profile @profile end |
#progress ⇒ Object
Returns the value of attribute progress.
5 6 7 |
# File 'lib/playstationnetwork/u/user.rb', line 5 def progress @progress end |
#projected_level ⇒ Object
Returns the value of attribute projected_level.
5 6 7 |
# File 'lib/playstationnetwork/u/user.rb', line 5 def projected_level @projected_level end |
#projected_progress ⇒ Object
Returns the value of attribute projected_progress.
5 6 7 |
# File 'lib/playstationnetwork/u/user.rb', line 5 def projected_progress @projected_progress end |
#region ⇒ Object
Returns the value of attribute region.
5 6 7 |
# File 'lib/playstationnetwork/u/user.rb', line 5 def region @region end |
#region_rank ⇒ Object
Returns the value of attribute region_rank.
5 6 7 |
# File 'lib/playstationnetwork/u/user.rb', line 5 def region_rank @region_rank end |
#silver ⇒ Object
Returns the value of attribute silver.
5 6 7 |
# File 'lib/playstationnetwork/u/user.rb', line 5 def silver @silver end |
#stats ⇒ Object
Returns the value of attribute stats.
5 6 7 |
# File 'lib/playstationnetwork/u/user.rb', line 5 def stats @stats end |
#total ⇒ Object
Returns the value of attribute total.
5 6 7 |
# File 'lib/playstationnetwork/u/user.rb', line 5 def total @total end |
#total_games ⇒ Object
Returns the value of attribute total_games.
5 6 7 |
# File 'lib/playstationnetwork/u/user.rb', line 5 def total_games @total_games end |
#total_possible ⇒ Object
Returns the value of attribute total_possible.
5 6 7 |
# File 'lib/playstationnetwork/u/user.rb', line 5 def total_possible @total_possible end |
#trophies ⇒ Object
Returns the value of attribute trophies.
5 6 7 |
# File 'lib/playstationnetwork/u/user.rb', line 5 def trophies @trophies end |
#username ⇒ Object
Returns the value of attribute username.
5 6 7 |
# File 'lib/playstationnetwork/u/user.rb', line 5 def username @username end |
#world_rank ⇒ Object
Returns the value of attribute world_rank.
5 6 7 |
# File 'lib/playstationnetwork/u/user.rb', line 5 def world_rank @world_rank end |
Class Method Details
.profile(psn_user_id) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/playstationnetwork/u/user.rb', line 75 def self.profile(psn_user_id) = PlayStationNetwork::API.config.merge({ user_id: psn_user_id }) response = PlayStationNetwork::API.post('/psnGetUser', body: ) if response.success? parsed = JSON.parse(response) self.new( parsed['psnplus'], parsed['avatar'], parsed['psn_id'], parsed['about_me'], parsed['country'], parsed['region'], parsed['total'], parsed['platinum'], parsed['gold'], parsed['silver'], parsed['bronze'], parsed['total_possible_trophies'], parsed['base'], parsed['points'], parsed['next'], parsed['level'], parsed['projected_level'], parsed['progress'], parsed['projected_progress'], parsed['total_games'], parsed['games_complete'], parsed['completion_percentage'], parsed['worldrank'], parsed['regionrank'], parsed['hardcore_rank'] ) else raise response.response end end |