Class: Sportradar::Nba::Models::Quarter
- Inherits:
-
Object
- Object
- Sportradar::Nba::Models::Quarter
- Defined in:
- lib/sportradar/nba/models/quarter.rb
Instance Method Summary collapse
- #abbreviation ⇒ Object
- #events ⇒ Object
- #events_data ⇒ Object
- #fouls ⇒ Object
- #game_id ⇒ Object
- #id ⇒ Object
-
#initialize(game_id:, attributes:) ⇒ Quarter
constructor
A new instance of Quarter.
- #number ⇒ Object
- #on_court_players ⇒ Object
- #scoring_plays ⇒ Object
- #sequence ⇒ Object
- #stoppages ⇒ Object
- #to_s ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(game_id:, attributes:) ⇒ Quarter
Returns a new instance of Quarter.
5 6 7 8 9 |
# File 'lib/sportradar/nba/models/quarter.rb', line 5 def initialize(game_id:, attributes:) @game_id = game_id @attributes = attributes build_events end |
Instance Method Details
#abbreviation ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/sportradar/nba/models/quarter.rb', line 15 def abbreviation case type when 'quarter' "#{number}Q" when 'overtime' "#{number}OT" else "#{number}" end end |
#events ⇒ Object
46 47 48 |
# File 'lib/sportradar/nba/models/quarter.rb', line 46 def events @events ||= [] end |
#events_data ⇒ Object
50 51 52 |
# File 'lib/sportradar/nba/models/quarter.rb', line 50 def events_data @actions ||= @attributes.dig('events') || [] end |
#fouls ⇒ Object
54 55 56 |
# File 'lib/sportradar/nba/models/quarter.rb', line 54 def fouls events.collect(&:foul).compact end |
#game_id ⇒ Object
26 27 28 |
# File 'lib/sportradar/nba/models/quarter.rb', line 26 def game_id @game_id end |
#id ⇒ Object
30 31 32 |
# File 'lib/sportradar/nba/models/quarter.rb', line 30 def id @id end |
#number ⇒ Object
34 35 36 |
# File 'lib/sportradar/nba/models/quarter.rb', line 34 def number @attributes['number'] || 0 end |
#on_court_players ⇒ Object
66 67 68 |
# File 'lib/sportradar/nba/models/quarter.rb', line 66 def on_court_players events.map(&:on_court_players).flatten end |
#scoring_plays ⇒ Object
58 59 60 |
# File 'lib/sportradar/nba/models/quarter.rb', line 58 def scoring_plays events.collect(&:scoring_play).compact end |
#sequence ⇒ Object
38 39 40 |
# File 'lib/sportradar/nba/models/quarter.rb', line 38 def sequence @attributes['sequence'] || 0 end |
#stoppages ⇒ Object
62 63 64 |
# File 'lib/sportradar/nba/models/quarter.rb', line 62 def stoppages events.collect(&:stoppage).compact end |
#to_s ⇒ Object
11 12 13 |
# File 'lib/sportradar/nba/models/quarter.rb', line 11 def to_s "#{type.titleize} #{number}" end |
#type ⇒ Object
42 43 44 |
# File 'lib/sportradar/nba/models/quarter.rb', line 42 def type @attributes['type'] end |