class Sportradar::Nba::Models::Quarter
Public Class Methods
new(game_id:, attributes:)
click to toggle source
# File lib/sportradar/nba/models/quarter.rb, line 5 def initialize(game_id:, attributes:) @game_id = game_id @attributes = attributes build_events end
Public Instance Methods
abbreviation()
click to toggle source
# 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()
click to toggle source
# File lib/sportradar/nba/models/quarter.rb, line 46 def events @events ||= [] end
events_data()
click to toggle source
# File lib/sportradar/nba/models/quarter.rb, line 50 def events_data @actions ||= @attributes.dig('events') || [] end
fouls()
click to toggle source
# File lib/sportradar/nba/models/quarter.rb, line 54 def fouls events.collect(&:foul).compact end
game_id()
click to toggle source
# File lib/sportradar/nba/models/quarter.rb, line 26 def game_id @game_id end
id()
click to toggle source
# File lib/sportradar/nba/models/quarter.rb, line 30 def id @id end
number()
click to toggle source
# File lib/sportradar/nba/models/quarter.rb, line 34 def number @attributes['number'] || 0 end
on_court_players()
click to toggle source
# File lib/sportradar/nba/models/quarter.rb, line 66 def on_court_players events.map(&:on_court_players).flatten end
scoring_plays()
click to toggle source
# File lib/sportradar/nba/models/quarter.rb, line 58 def scoring_plays events.collect(&:scoring_play).compact end
sequence()
click to toggle source
# File lib/sportradar/nba/models/quarter.rb, line 38 def sequence @attributes['sequence'] || 0 end
stoppages()
click to toggle source
# File lib/sportradar/nba/models/quarter.rb, line 62 def stoppages events.collect(&:stoppage).compact end
to_s()
click to toggle source
# File lib/sportradar/nba/models/quarter.rb, line 11 def to_s "#{type.titleize} #{number}" end
type()
click to toggle source
# File lib/sportradar/nba/models/quarter.rb, line 42 def type @attributes['type'] end
Private Instance Methods
build_events()
click to toggle source
# File lib/sportradar/nba/models/quarter.rb, line 72 def build_events events_data.each do |event_data| events << Models::Event.new(quarter: self, attributes: event_data) end end