Sha256: 206f9946e3345229a9c3b0a1b4e973cc867a71087dcfd6c4489869ee9f58db0f

Contents?: true

Size: 1.22 KB

Versions: 112

Compression:

Stored size: 1.22 KB

Contents

module Sportradar
  module Api
    class Nfl::TeamDepthChart < Data
      include Enumerable
      attr_accessor :response, :season, :team_id, :abbrev

      # data.keys => ["offense", "defense", "special_teams", "name", "market", "alias", "id"]
      def initialize(data, season)
        @response = data
        @season = season
        @team_id = response['id']
        @abbrev = response['alias']
      end

      def offense
        @offense ||= Sportradar::Api::Nfl::DepthChart.new(response['offense']) if response['offense']
      end

      def defense
        @defense ||= Sportradar::Api::Nfl::DepthChart.new(response['defense']) if response['defense']
      end

      def special_teams
        @special_teams ||= Sportradar::Api::Nfl::DepthChart.new(response['special_teams']) if response['special_teams']
      end

      def team
        @team ||= Sportradar::Api::Nfl::Team.new(response).tap { |team| team.depth_chart = self }
      end

      def each
        [:offense, :defense, :special_teams].each { |type| yield type, send(type) }
      end

      # These aren't ever used, but handy if you need to invoke for testing
      # private

      # def set_charts
      #   [offense, defense, special_teams]
      # end

    end
  end
end

Version data entries

112 entries across 112 versions & 1 rubygems

Version Path
sportradar-api-0.10.55 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.54 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.53 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.52 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.51 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.50 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.49 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.48 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.47 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.46 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.45 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.44 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.43 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.42 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.41 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.40 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.39 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.38 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.37 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.36 lib/sportradar/api/nfl/team_depth_chart.rb