Sha256: 2f1845fc1ffed641448d95207f410a8ce75ebfee3652c515eba7b380b9584c03

Contents?: true

Size: 936 Bytes

Versions: 1

Compression:

Stored size: 936 Bytes

Contents

module Sportradar
  module Api
    class Nfl::Season < Data
      attr_accessor :response, :id, :year, :type, :name, :weeks, :injuries, :team

      def initialize(data)
        @response = data
        @id = data["id"]
        @year = data["year"]
        @type = data["type"]
        @name = data["name"]
        @team = Sportradar::Api::Nfl::Team.new(data["team"]) if data["team"].is_a?(Hash)
        @injuries = data["injuries"]["team"].map {|team| Sportradar::Api::Nfl::Team.new team } if data["injuries"] && data["injuries"]["team"]
        set_weeks
      end

      private

      def set_weeks
        if response["week"]
          if response["week"].is_a?(Array)
            @weeks = response["week"].map {|week| Sportradar::Api::Nfl::Week.new week }
          elsif response["week"].is_a?(Hash)
            @weeks = [ Sportradar::Api::Nfl::Week.new(response["week"]) ]
          end
        end
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sportradar-api-0.1.24 lib/sportradar/api/nfl/season.rb