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.12 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.9.11 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.9.10 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.9.9 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.9.8 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.9.7 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.9.6 lib/sportradar/api/nfl/league_depth_chart.rb
sportradar-api-0.9.5 lib/sportradar/api/nfl/league_depth_chart.rb