Class: PlayStationNetwork::G::Game
- Inherits:
-
Object
- Object
- PlayStationNetwork::G::Game
- Defined in:
- lib/playstationnetwork/g/game.rb
Instance Attribute Summary collapse
-
#average_percentage ⇒ Object
Returns the value of attribute average_percentage.
-
#bronze ⇒ Object
Returns the value of attribute bronze.
-
#checked ⇒ Object
Returns the value of attribute checked.
-
#completers ⇒ Object
Returns the value of attribute completers.
-
#completers_platinum ⇒ Object
Returns the value of attribute completers_platinum.
-
#cover ⇒ Object
Returns the value of attribute cover.
-
#gold ⇒ Object
Returns the value of attribute gold.
-
#media ⇒ Object
Returns the value of attribute media.
-
#name ⇒ Object
Returns the value of attribute name.
-
#owners ⇒ Object
Returns the value of attribute owners.
-
#platforms ⇒ Object
Returns the value of attribute platforms.
-
#platinum ⇒ Object
Returns the value of attribute platinum.
-
#played_this_week ⇒ Object
Returns the value of attribute played_this_week.
-
#points ⇒ Object
Returns the value of attribute points.
-
#points_platinum ⇒ Object
Returns the value of attribute points_platinum.
-
#psn_hash ⇒ Object
Returns the value of attribute psn_hash.
-
#psn_id ⇒ Object
Returns the value of attribute psn_id.
-
#psn_slug ⇒ Object
Returns the value of attribute psn_slug.
-
#psn_type ⇒ Object
Returns the value of attribute psn_type.
-
#silver ⇒ Object
Returns the value of attribute silver.
-
#stats ⇒ Object
Returns the value of attribute stats.
-
#total ⇒ Object
Returns the value of attribute total.
-
#trophies ⇒ Object
Returns the value of attribute trophies.
-
#trophies_earned ⇒ Object
Returns the value of attribute trophies_earned.
-
#updated ⇒ Object
Returns the value of attribute updated.
-
#updates ⇒ Object
Returns the value of attribute updates.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(psn_id, psn_hash, psn_type, psn_slug, name, cover, platforms, updated, checked, artworks, videos, total, platinum, gold, silver, bronze, points, points_platinum, average_percentage, owners, completers, completers_platinum, trophies_earned, played_this_week) ⇒ Game
constructor
A new instance of Game.
Constructor Details
#initialize(psn_id, psn_hash, psn_type, psn_slug, name, cover, platforms, updated, checked, artworks, videos, total, platinum, gold, silver, bronze, points, points_platinum, average_percentage, owners, completers, completers_platinum, trophies_earned, played_this_week) ⇒ Game
Returns a new instance of Game.
11 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 |
# File 'lib/playstationnetwork/g/game.rb', line 11 def initialize( psn_id, psn_hash, psn_type, psn_slug, name, cover, platforms, updated, checked, artworks, videos, total, platinum, gold, silver, bronze, points, points_platinum, average_percentage, owners, completers, completers_platinum, trophies_earned, played_this_week ) game_updates = Hash.new game_updates[:last_updated] = updated game_updates[:last_checked] = checked game_media = Hash.new game_media[:artworks] = artworks game_media[:videos] = videos game_trophies = Hash.new game_trophies[:total] = total game_trophies[:platinum] = platinum game_trophies[:gold] = gold game_trophies[:silver] = silver game_trophies[:bronze] = bronze game_stats = Hash.new game_stats[:points] = points game_stats[:points_platinum] = points_platinum game_stats[:average_percentage] = "#{average_percentage}%" game_stats[:owners] = owners game_stats[:completers] = completers game_stats[:completers_platinum] = completers_platinum game_stats[:trophies_earned] = trophies_earned game_stats[:played_this_week] = played_this_week self.psn_id = psn_id self.psn_hash = psn_hash self.psn_type = psn_type self.psn_slug = psn_slug self.name = name self.cover = cover self.platforms = platforms.split(',') self.media = game_media self.updates = game_updates self.trophies = game_trophies self.stats = game_stats end |
Instance Attribute Details
#average_percentage ⇒ Object
Returns the value of attribute average_percentage.
5 6 7 |
# File 'lib/playstationnetwork/g/game.rb', line 5 def average_percentage @average_percentage end |
#bronze ⇒ Object
Returns the value of attribute bronze.
5 6 7 |
# File 'lib/playstationnetwork/g/game.rb', line 5 def bronze @bronze end |
#checked ⇒ Object
Returns the value of attribute checked.
5 6 7 |
# File 'lib/playstationnetwork/g/game.rb', line 5 def checked @checked end |
#completers ⇒ Object
Returns the value of attribute completers.
5 6 7 |
# File 'lib/playstationnetwork/g/game.rb', line 5 def completers @completers end |
#completers_platinum ⇒ Object
Returns the value of attribute completers_platinum.
5 6 7 |
# File 'lib/playstationnetwork/g/game.rb', line 5 def completers_platinum @completers_platinum end |
#cover ⇒ Object
Returns the value of attribute cover.
5 6 7 |
# File 'lib/playstationnetwork/g/game.rb', line 5 def cover @cover end |
#gold ⇒ Object
Returns the value of attribute gold.
5 6 7 |
# File 'lib/playstationnetwork/g/game.rb', line 5 def gold @gold end |
#media ⇒ Object
Returns the value of attribute media.
5 6 7 |
# File 'lib/playstationnetwork/g/game.rb', line 5 def media @media end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/playstationnetwork/g/game.rb', line 5 def name @name end |
#owners ⇒ Object
Returns the value of attribute owners.
5 6 7 |
# File 'lib/playstationnetwork/g/game.rb', line 5 def owners @owners end |
#platforms ⇒ Object
Returns the value of attribute platforms.
5 6 7 |
# File 'lib/playstationnetwork/g/game.rb', line 5 def platforms @platforms end |
#platinum ⇒ Object
Returns the value of attribute platinum.
5 6 7 |
# File 'lib/playstationnetwork/g/game.rb', line 5 def platinum @platinum end |
#played_this_week ⇒ Object
Returns the value of attribute played_this_week.
5 6 7 |
# File 'lib/playstationnetwork/g/game.rb', line 5 def played_this_week @played_this_week end |
#points ⇒ Object
Returns the value of attribute points.
5 6 7 |
# File 'lib/playstationnetwork/g/game.rb', line 5 def points @points end |
#points_platinum ⇒ Object
Returns the value of attribute points_platinum.
5 6 7 |
# File 'lib/playstationnetwork/g/game.rb', line 5 def points_platinum @points_platinum end |
#psn_hash ⇒ Object
Returns the value of attribute psn_hash.
5 6 7 |
# File 'lib/playstationnetwork/g/game.rb', line 5 def psn_hash @psn_hash end |
#psn_id ⇒ Object
Returns the value of attribute psn_id.
5 6 7 |
# File 'lib/playstationnetwork/g/game.rb', line 5 def psn_id @psn_id end |
#psn_slug ⇒ Object
Returns the value of attribute psn_slug.
5 6 7 |
# File 'lib/playstationnetwork/g/game.rb', line 5 def psn_slug @psn_slug end |
#psn_type ⇒ Object
Returns the value of attribute psn_type.
5 6 7 |
# File 'lib/playstationnetwork/g/game.rb', line 5 def psn_type @psn_type end |
#silver ⇒ Object
Returns the value of attribute silver.
5 6 7 |
# File 'lib/playstationnetwork/g/game.rb', line 5 def silver @silver end |
#stats ⇒ Object
Returns the value of attribute stats.
5 6 7 |
# File 'lib/playstationnetwork/g/game.rb', line 5 def stats @stats end |
#total ⇒ Object
Returns the value of attribute total.
5 6 7 |
# File 'lib/playstationnetwork/g/game.rb', line 5 def total @total end |
#trophies ⇒ Object
Returns the value of attribute trophies.
5 6 7 |
# File 'lib/playstationnetwork/g/game.rb', line 5 def trophies @trophies end |
#trophies_earned ⇒ Object
Returns the value of attribute trophies_earned.
5 6 7 |
# File 'lib/playstationnetwork/g/game.rb', line 5 def trophies_earned @trophies_earned end |
#updated ⇒ Object
Returns the value of attribute updated.
5 6 7 |
# File 'lib/playstationnetwork/g/game.rb', line 5 def updated @updated end |
#updates ⇒ Object
Returns the value of attribute updates.
5 6 7 |
# File 'lib/playstationnetwork/g/game.rb', line 5 def updates @updates end |
Class Method Details
.find(psn_game_id) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/playstationnetwork/g/game.rb', line 57 def self.find(psn_game_id) = PlayStationNetwork::API.config.merge({ npcommid: psn_game_id }) response = PlayStationNetwork::API.post('/psnGetGame', body: ) if response.success? parsed = JSON.parse(response) new( parsed['npcommid'], parsed['game_hash'], parsed['content_Type'], parsed['unique_url'], parsed['title'], parsed['image'], parsed['pf'], parsed['updated'].to_i, parsed['meta_check'].to_i, parsed['screenshots'], parsed['videos'], parsed['total'].to_i, parsed['platinum'].to_i, parsed['gold'].to_i, parsed['silver'].to_i, parsed['bronze'].to_i, parsed['total_points'].to_i, parsed['total_points_plat'].to_i, parsed['average_perc'].to_f, parsed['owners'].to_i, parsed['completers'].to_i, parsed['platters'].to_i, parsed['trophies_earned'].to_i, parsed['played_this_week'].to_i ) else raise response.response end end |