lib/sportradar/api/basketball/nba/player.rb in sportradar-api-0.9.34 vs lib/sportradar/api/basketball/nba/player.rb in sportradar-api-0.9.35

- old
+ new

@@ -1,11 +1,11 @@ module Sportradar module Api module Basketball class Nba class Player < Data - attr_accessor :response, :id, :number, :full_name, :first_name, :last_name, :position, :birth_date, :birth_place, :college, :height, :weight, :birth_place, :college + attr_accessor :response, :id, :number, :full_name, :first_name, :last_name, :position, :birth_date, :birth_place, :college, :height, :weight, :birth_place, :college, :averages, :draft # @all_hash = {} # def self.new(data, **opts) # existing = @all_hash[data['id']] # if existing # existing.update(data, **opts) @@ -65,12 +65,15 @@ @updated = data['updated'] if data['updated'] # "2016-07-08T12:11:59+00:00", update_injuries(data) update_draft(data) @team.update_player_stats(self, data['statistics'], opts[:game]) if data['statistics'] - @team.update_player_stats(self, data.dig('overall', 'average')) if data.dig('overall', 'average') - + if avgs = data.dig('overall', 'average') + @averages = avgs + @team.update_player_stats(self, @averages) + end + self end def age if birth_date.present? @@ -113,13 +116,13 @@ # "flagrant_fouls"=>"0", # "pls_min"=>"4", # "points"=>"13"}} # end def update_draft(data) - @draft = data['draft'] # {"team_id"=>"583ec825-fb46-11e1-82cb-f4ce4684ea4c", "year"=>"2012", "round"=>"1", "pick"=>"30"}, + @draft = data['draft'] if data['draft'] # {"team_id"=>"583ec825-fb46-11e1-82cb-f4ce4684ea4c", "year"=>"2012", "round"=>"1", "pick"=>"30"}, end def update_injuries(data) - @injuries = data['injuries'] # + @injuries = data['injuries'] if data['injuries'] # # {"injury"=> # {"id"=>"06423591-3fc1-4d2b-8c60-a3f30d735345", # "comment"=>"Ezeli suffered a setback in his recovery from a procedure on his knee and there is no timetable for his return, according to Jason Quick of csnnw.com.", # "desc"=>"Knee", # "status"=>"Out",