Sha256: e82d36eca882ac3ec375ce077d61173c3a7032349cf71fad3ac23c587c354084

Contents?: true

Size: 867 Bytes

Versions: 108

Compression:

Stored size: 867 Bytes

Contents

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

      def initialize(data)
        @response = data
        depth_chart_data = data['depth_charts']
        @season = Sportradar::Api::Nfl::Season.new data
        # @teams = depth_chart_data["team"].map {|team| Sportradar::Api::Nfl::Team.new team } if depth_chart_data["team"]
        @charts = depth_chart_data["team"].map {|team| Sportradar::Api::Nfl::TeamDepthChart.new(team, season) } if depth_chart_data["team"]
      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

Version data entries

108 entries across 108 versions & 1 rubygems

Version Path
sportradar-api-0.9.32 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.9.31 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.9.30 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.9.29 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.9.28 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.9.27 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.9.26 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.9.25 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.9.24 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.9.23 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.9.22 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.9.21 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.9.20 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.9.19 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.9.18 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.9.17 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.9.16 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.9.15 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.9.14 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.9.13 lib/sportradar/api/nfl/league_depth_chart.rb