Class: GameLockerAPI::Player
- Inherits:
-
Object
- Object
- GameLockerAPI::Player
- Defined in:
- lib/gamelocker_api/player.rb
Instance Attribute Summary collapse
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#games_played ⇒ Object
Returns the value of attribute games_played.
-
#guild_tag ⇒ Object
Returns the value of attribute guild_tag.
-
#karma_level ⇒ Object
Returns the value of attribute karma_level.
-
#level ⇒ Object
Returns the value of attribute level.
-
#loses ⇒ Object
Returns the value of attribute loses.
-
#name ⇒ Object
Returns the value of attribute name.
-
#rank_points ⇒ Object
Returns the value of attribute rank_points.
-
#shard_id ⇒ Object
Returns the value of attribute shard_id.
-
#skill_tier ⇒ Object
Returns the value of attribute skill_tier.
-
#total_games_played ⇒ Object
Returns the value of attribute total_games_played.
-
#uuid ⇒ Object
Returns the value of attribute uuid.
-
#wins ⇒ Object
Returns the value of attribute wins.
-
#xp ⇒ Object
Returns the value of attribute xp.
Instance Method Summary collapse
- #calculate_loses ⇒ Object
- #calculate_total_games_played ⇒ Object
-
#initialize(data) ⇒ Player
constructor
A new instance of Player.
Constructor Details
#initialize(data) ⇒ Player
Returns a new instance of Player.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/gamelocker_api/player.rb', line 7 def initialize(data) self.uuid = data['id'] self.name = data['attributes']['name'] self.created_at = data['attributes']['createdAt'] self.games_played = data['attributes']['stats']['gamesPlayed'] self.guild_tag = data['attributes']['stats']['guildTag'] self.karma_level = data['attributes']['stats']['karmaLevel'] self.level = data['attributes']['stats']['level'] self.rank_points = data['attributes']['stats']['rank_points'] self.skill_tier = data['attributes']['stats']['skillTier'] self.wins = data['attributes']['stats']['wins'] self.xp = data['attributes']['stats']['xp'] calculate_total_games_played calculate_loses return self end |
Instance Attribute Details
#created_at ⇒ Object
Returns the value of attribute created_at.
3 4 5 |
# File 'lib/gamelocker_api/player.rb', line 3 def created_at @created_at end |
#games_played ⇒ Object
Returns the value of attribute games_played.
4 5 6 |
# File 'lib/gamelocker_api/player.rb', line 4 def games_played @games_played end |
#guild_tag ⇒ Object
Returns the value of attribute guild_tag.
4 5 6 |
# File 'lib/gamelocker_api/player.rb', line 4 def guild_tag @guild_tag end |
#karma_level ⇒ Object
Returns the value of attribute karma_level.
4 5 6 |
# File 'lib/gamelocker_api/player.rb', line 4 def karma_level @karma_level end |
#level ⇒ Object
Returns the value of attribute level.
4 5 6 |
# File 'lib/gamelocker_api/player.rb', line 4 def level @level end |
#loses ⇒ Object
Returns the value of attribute loses.
5 6 7 |
# File 'lib/gamelocker_api/player.rb', line 5 def loses @loses end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/gamelocker_api/player.rb', line 3 def name @name end |
#rank_points ⇒ Object
Returns the value of attribute rank_points.
4 5 6 |
# File 'lib/gamelocker_api/player.rb', line 4 def rank_points @rank_points end |
#shard_id ⇒ Object
Returns the value of attribute shard_id.
3 4 5 |
# File 'lib/gamelocker_api/player.rb', line 3 def shard_id @shard_id end |
#skill_tier ⇒ Object
Returns the value of attribute skill_tier.
4 5 6 |
# File 'lib/gamelocker_api/player.rb', line 4 def skill_tier @skill_tier end |
#total_games_played ⇒ Object
Returns the value of attribute total_games_played.
5 6 7 |
# File 'lib/gamelocker_api/player.rb', line 5 def total_games_played @total_games_played end |
#uuid ⇒ Object
Returns the value of attribute uuid.
3 4 5 |
# File 'lib/gamelocker_api/player.rb', line 3 def uuid @uuid end |
#wins ⇒ Object
Returns the value of attribute wins.
4 5 6 |
# File 'lib/gamelocker_api/player.rb', line 4 def wins @wins end |
#xp ⇒ Object
Returns the value of attribute xp.
4 5 6 |
# File 'lib/gamelocker_api/player.rb', line 4 def xp @xp end |
Instance Method Details
#calculate_loses ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/gamelocker_api/player.rb', line 35 def calculate_loses games = 0 self.games_played.each do |mode, n| games+=n end self.loses = games-wins end |
#calculate_total_games_played ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/gamelocker_api/player.rb', line 26 def calculate_total_games_played games = 0 self.games_played.each do |mode, n| games+=n end self.total_games_played = games end |