Sha256: c1e3bd78467229dbe0ddb978fc49517557079d86087f4a49187043d4219c658e

Contents?: true

Size: 581 Bytes

Versions: 14

Compression:

Stored size: 581 Bytes

Contents

module SportsDataApi
  module Nfl
    class PlayByPlays
      include Enumerable
      attr_reader :events

      def initialize(pbp_events)
        @events = pbp_events.map do |pbp_event|
          if pbp_event["type"] == "event"
            Event.new(pbp_event)
          elsif pbp_event["type"] == "drive"
            Drive.new(pbp_event)
          end
        end
      end

      def each &block
        @events.each do |event|
          if block_given?
            block.call event
          else
            yield event
          end
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
sports_data_api-0.14.1 lib/sports_data_api/nfl/play_by_plays.rb
sports_data_api-0.14.0 lib/sports_data_api/nfl/play_by_plays.rb
sports_data_api-0.13.0 lib/sports_data_api/nfl/play_by_plays.rb
sports_data_api-0.12.1 lib/sports_data_api/nfl/play_by_plays.rb
sports_data_api-0.12.0 lib/sports_data_api/nfl/play_by_plays.rb
sports_data_api-0.11.6 lib/sports_data_api/nfl/play_by_plays.rb
sports_data_api-0.11.5 lib/sports_data_api/nfl/play_by_plays.rb
sports_data_api-0.11.3 lib/sports_data_api/nfl/play_by_plays.rb
sports_data_api-0.11.2 lib/sports_data_api/nfl/play_by_plays.rb
sports_data_api-0.11.1 lib/sports_data_api/nfl/play_by_plays.rb
sports_data_api-0.11.0 lib/sports_data_api/nfl/play_by_plays.rb
sports_data_api-0.10.1 lib/sports_data_api/nfl/play_by_plays.rb
sports_data_api-0.10.0 lib/sports_data_api/nfl/play_by_plays.rb
sports_data_api-0.9.2 lib/sports_data_api/nfl/play_by_plays.rb