Sha256: f297131ecb6b271985a01818b38bca575544f3dc527a5fcb2a2569e8f2f28997
Contents?: true
Size: 2 KB
Versions: 18
Compression:
Stored size: 2 KB
Contents
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 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"] @position = data["position"] @reference = data["reference"] @sequence = data["sequence"] @title = data["title"] @age = data["age"] @birth_date = data["birth_date"] @birth_place = data["birth_place"] @college = data["college"] @college_conf = data["college_conf"] @first_name = data["first_name"] @height = data["height"] @high_school = data["high_school"] @last_name = data["last_name"] @preferred_name = data["preferred_name"] @references = data["references"] @rookie_year = data["rookie_year"] @status = data["status"] @weight = data["weight"] @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 age if birth_date.present? now = Time.now.utc.to_date dob = birth_date.to_date now.year - dob.year - ((now.month > dob.month || (now.month == dob.month && now.day >= dob.day)) ? 0 : 1) end end end end end
Version data entries
18 entries across 18 versions & 1 rubygems