Sha256: 6a6c85097b5914f6b31d2396b9a18003734647c17664b0b8659819e79bdd9088

Contents?: true

Size: 1000 Bytes

Versions: 108

Compression:

Stored size: 1000 Bytes

Contents

module Sportradar
  module Api
    module Football
      class Nfl
        class LeagueDepthChart < Data
          include Enumerable
          attr_accessor :response, :week_number, :charts

          def initialize(data, **opts)
            @response = data
            @charts_hash = {}

            update(data, **opts)
          end

          def update(data, **opts)
            @week = data['week']
            @week_number = data.dig('week', 'sequence')
            create_data(@charts_hash, data["teams"], klass: TeamDepthChart, api: opts[:api])

            self
          end

          def charts
            @charts_hash.values
          end

          # id is preferred search, but we allow for team abbreviation too
          def team(id = nil, abbrev: nil)
            charts.detect { |chart| chart.team_id == id || chart.abbrev == abbrev }
          end

          def each
            self.charts.each { |chart| yield chart }
          end

        end
      end
    end
  end
end

Version data entries

108 entries across 108 versions & 1 rubygems

Version Path
sportradar-api-0.20.2 lib/sportradar/api/football/nfl/league_depth_chart.rb
sportradar-api-0.20.1 lib/sportradar/api/football/nfl/league_depth_chart.rb
sportradar-api-0.20.0 lib/sportradar/api/football/nfl/league_depth_chart.rb
sportradar-api-0.20.0.pre2 lib/sportradar/api/football/nfl/league_depth_chart.rb
sportradar-api-0.20.0.pre lib/sportradar/api/football/nfl/league_depth_chart.rb
sportradar-api-0.19.6 lib/sportradar/api/football/nfl/league_depth_chart.rb
sportradar-api-0.19.5 lib/sportradar/api/football/nfl/league_depth_chart.rb
sportradar-api-0.19.4 lib/sportradar/api/football/nfl/league_depth_chart.rb
sportradar-api-0.19.3 lib/sportradar/api/football/nfl/league_depth_chart.rb
sportradar-api-0.19.2 lib/sportradar/api/football/nfl/league_depth_chart.rb
sportradar-api-0.19.1 lib/sportradar/api/football/nfl/league_depth_chart.rb
sportradar-api-0.19.0 lib/sportradar/api/football/nfl/league_depth_chart.rb
sportradar-api-0.18.1 lib/sportradar/api/football/nfl/league_depth_chart.rb
sportradar-api-0.18.0 lib/sportradar/api/football/nfl/league_depth_chart.rb
sportradar-api-0.17.6 lib/sportradar/api/football/nfl/league_depth_chart.rb
sportradar-api-0.17.5 lib/sportradar/api/football/nfl/league_depth_chart.rb
sportradar-api-0.17.5.pre lib/sportradar/api/football/nfl/league_depth_chart.rb
sportradar-api-0.17.4 lib/sportradar/api/football/nfl/league_depth_chart.rb
sportradar-api-0.17.3 lib/sportradar/api/football/nfl/league_depth_chart.rb
sportradar-api-0.17.2 lib/sportradar/api/football/nfl/league_depth_chart.rb