Sha256: e73c14a4ccbb453e24082bee43baac0927d37800621f4ede2ed718b6419e265c

Contents?: true

Size: 923 Bytes

Versions: 17

Compression:

Stored size: 923 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"]
        @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

17 entries across 17 versions & 1 rubygems

Version Path
sportradar-api-0.1.23 lib/sportradar/api/nfl/season.rb
sportradar-api-0.1.22 lib/sportradar/api/nfl/season.rb
sportradar-api-0.1.21 lib/sportradar/api/nfl/season.rb
sportradar-api-0.1.19 lib/sportradar/api/nfl/season.rb
sportradar-api-0.1.18 lib/sportradar/api/nfl/season.rb
sportradar-api-0.1.17 lib/sportradar/api/nfl/season.rb
sportradar-api-0.1.16 lib/sportradar/api/nfl/season.rb
sportradar-api-0.1.15 lib/sportradar/api/nfl/season.rb
sportradar-api-0.1.14 lib/sportradar/api/nfl/season.rb
sportradar-api-0.1.13 lib/sportradar/api/nfl/season.rb
sportradar-api-0.1.12 lib/sportradar/api/nfl/season.rb
sportradar-api-0.1.11 lib/sportradar/api/nfl/season.rb
sportradar-api-0.1.10 lib/sportradar/api/nfl/season.rb
sportradar-api-0.1.8 lib/sportradar/api/nfl/season.rb
sportradar-api-0.1.7 lib/sportradar/api/nfl/season.rb
sportradar-api-0.1.6 lib/sportradar/api/nfl/season.rb
sportradar-api-0.1.5 lib/sportradar/api/nfl/season.rb