Class: SportsDataApi::Nfl::PlayByPlays
- Inherits:
-
Object
- Object
- SportsDataApi::Nfl::PlayByPlays
- Includes:
- Enumerable
- Defined in:
- lib/sports_data_api/nfl/play_by_plays.rb
Instance Attribute Summary collapse
-
#events ⇒ Object
readonly
Returns the value of attribute events.
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(pbp_events) ⇒ PlayByPlays
constructor
A new instance of PlayByPlays.
Constructor Details
#initialize(pbp_events) ⇒ PlayByPlays
7 8 9 10 11 12 13 14 15 |
# File 'lib/sports_data_api/nfl/play_by_plays.rb', line 7 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 |
Instance Attribute Details
#events ⇒ Object (readonly)
Returns the value of attribute events.
5 6 7 |
# File 'lib/sports_data_api/nfl/play_by_plays.rb', line 5 def events @events end |
Instance Method Details
#each(&block) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/sports_data_api/nfl/play_by_plays.rb', line 17 def each &block @events.each do |event| if block_given? block.call event else yield event end end end |