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