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.55 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.10.54 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.10.53 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.10.52 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.10.51 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.10.50 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.10.49 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.10.48 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.10.47 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.10.46 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.10.45 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.10.44 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.10.43 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.10.42 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.10.41 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.10.40 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.10.39 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.10.38 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.10.37 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.10.36 lib/sportradar/api/nfl/league_depth_chart.rb