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.35 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.34 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.33 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.32 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.31 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.30 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.29 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.28 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.27 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.26 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.25 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.24 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.23 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.22 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.21 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.20 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.19 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.18 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.17 lib/sportradar/api/nfl/team_depth_chart.rb
sportradar-api-0.10.16 lib/sportradar/api/nfl/team_depth_chart.rb