lib/sportradar/api/nfl/player.rb in sportradar-api-0.9.18 vs lib/sportradar/api/nfl/player.rb in sportradar-api-0.9.19
- old
+ new
@@ -1,18 +1,18 @@
module Sportradar
module Api
class Nfl::Player < Data
- attr_accessor :response, :id, :sequence, :title, :game, :name, :jersey, :reference, :position, :depth, :injury, :age, :birth_date, :birth_place, :college, :college_conf, :draft, :first_name, :height, :high_school, :last_name, :preferred_name, :references, :rookie_year, :status, :weight, :abbr_name, :seasons, :team
+ attr_accessor :response, :id, :sequence, :title, :game, :full_name, :jersey, :reference, :position, :depth, :injury, :age, :birth_date, :birth_place, :college, :college_conf, :draft, :first_name, :height, :high_school, :last_name, :preferred_name, :references, :rookie_year, :status, :weight, :abbr_name, :seasons, :team
def initialize(data)
data = [data].to_h if data.is_a? Array # for kickers in depth charts
@response = data
@depth = data["depth"]
@game = data["game"] # Games
@id = data["id"]
@jersey = data["jersey"]
- @name = data["name"]
+ @full_name = data["name"]
@position = data["position"]
@reference = data["reference"]
@sequence = data["sequence"]
@title = data["title"]
@age = data["age"]
@@ -32,9 +32,12 @@
@abbr_name = data["abbr_name"]
@team = Sportradar::Api::Nfl::Team.new data["team"] if data["team"]
@injury = Sportradar::Api::Nfl::Injury.new data["injury"] if data["injury"]
@draft = Sportradar::Api::Nfl::Draft.new data["draft"] if data["draft"]
@seasons = parse_into_array(selector: response["season"], klass: Sportradar::Api::Nfl::Season) if response["season"]
+ end
+ def name
+ @name ||= [(preferred_name || first_name), last_name].join(' ')
end
def age
if birth_date.present?
now = Time.now.utc.to_date