class Sportradar::Nfl::Models::Quarter

Public Class Methods

new(game_id:, attributes:) click to toggle source
# File lib/sportradar/nfl/models/quarter.rb, line 5
def initialize(game_id:, attributes:)
  @game_id = game_id
  @attributes = attributes
end

Public Instance Methods

abbreviation() click to toggle source
# File lib/sportradar/nfl/models/quarter.rb, line 14
def abbreviation
  "Q#{number}"
end
drives() click to toggle source
# File lib/sportradar/nfl/models/quarter.rb, line 30
def drives
  @drives ||= build_drives
end
game_id() click to toggle source
# File lib/sportradar/nfl/models/quarter.rb, line 18
def game_id
  @game_id
end
number() click to toggle source
# File lib/sportradar/nfl/models/quarter.rb, line 22
def number
  @attributes['number'] || 0
end
pbp() click to toggle source
# File lib/sportradar/nfl/models/quarter.rb, line 26
def pbp
  @attributes['pbp']
end
to_s() click to toggle source
# File lib/sportradar/nfl/models/quarter.rb, line 10
def to_s
  "Quarter #{number}"
end

Private Instance Methods

build_drives() click to toggle source
# File lib/sportradar/nfl/models/quarter.rb, line 36
def build_drives
  pbp.each_with_object([]) do |event, _drives|
    if event['type'] == 'drive'
      _drives << Models::Drive.new(quarter: self, attributes: event)
    end
  end
end