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.15 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.14 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.13 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.12 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.11 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.10 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.9 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.8 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.7 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.6 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.5 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.4 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.3 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.2 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.1 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.0 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.9.59 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.9.58 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.9.57 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.9.56 lib/sportradar/api/nfl/team_depth_chart.rb