Sha256: 287ec410d9c71b95be608f4744fb6764df08960f67653c21ae649b641c10dae5

Contents?: true

Size: 1.19 KB

Versions: 108

Compression:

Stored size: 1.19 KB

Contents

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

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

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

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

          def special_teams
            @special_teams ||= DepthChart.new(response['special_teams']) if response['special_teams']
          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
  end
end

Version data entries

108 entries across 108 versions & 1 rubygems

Version Path
sportradar-api-0.11.48 lib/sportradar/api/football/nfl/team_depth_chart.rb
sportradar-api-0.11.47 lib/sportradar/api/football/nfl/team_depth_chart.rb
sportradar-api-0.11.46 lib/sportradar/api/football/nfl/team_depth_chart.rb
sportradar-api-0.11.45 lib/sportradar/api/football/nfl/team_depth_chart.rb
sportradar-api-0.11.44 lib/sportradar/api/football/nfl/team_depth_chart.rb
sportradar-api-0.11.43 lib/sportradar/api/football/nfl/team_depth_chart.rb
sportradar-api-0.11.42 lib/sportradar/api/football/nfl/team_depth_chart.rb
sportradar-api-0.11.41 lib/sportradar/api/football/nfl/team_depth_chart.rb
sportradar-api-0.11.40 lib/sportradar/api/football/nfl/team_depth_chart.rb
sportradar-api-0.11.39 lib/sportradar/api/football/nfl/team_depth_chart.rb
sportradar-api-0.11.38 lib/sportradar/api/football/nfl/team_depth_chart.rb
sportradar-api-0.11.37 lib/sportradar/api/football/nfl/team_depth_chart.rb
sportradar-api-0.11.36 lib/sportradar/api/football/nfl/team_depth_chart.rb
sportradar-api-0.11.35 lib/sportradar/api/football/nfl/team_depth_chart.rb
sportradar-api-0.11.34 lib/sportradar/api/football/nfl/team_depth_chart.rb
sportradar-api-0.11.33 lib/sportradar/api/football/nfl/team_depth_chart.rb
sportradar-api-0.11.32 lib/sportradar/api/football/nfl/team_depth_chart.rb
sportradar-api-0.11.31 lib/sportradar/api/football/nfl/team_depth_chart.rb
sportradar-api-0.11.30 lib/sportradar/api/football/nfl/team_depth_chart.rb
sportradar-api-0.11.29 lib/sportradar/api/football/nfl/team_depth_chart.rb